/ Published in: Other
Credits to apex-lang package
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
global static String to18(String the15charID){ //a0BA0000000L2ZC => a0BA0000000L2ZCMA0 //the15charID = 'a0BA0000000L2ZC' final String BASE ='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'; the15charID = StringUtils.trim(the15charID); if(StringUtils.length(the15charID) != 15){ return the15charID; } String result = ''; List<String> chars = null; for(integer i = 0; i < 3; i++){ chars = StringUtils.toCharArray(StringUtils.reverse(the15charID.substring(i*5,i*5+5))); String binary = ''; for(String ch : chars){ binary += Character.isUpperCase(ch) ? '1' : '0'; } result += StringUtils.charAt(BASE,NumberUtils.parseInt(binary,2)); } return the15charID + result; }
URL: http://apex-lang.googlecode.com/svn/trunk/eclipse-project/src/classes/SystemUtils.cls