Java tutorial
//package com.java2s; public class Main { final static char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', }; public static String compress(String orderid) { if (orderid == null) { return ""; } String strNew1 = compressNumber(Long.parseLong(orderid.substring(4, 12)), 5); String strNew2 = compressNumber(Long.parseLong(orderid.substring(12, orderid.length())), 5); System.out.println(strNew1); System.out.println(strNew2); return strNew1 + strNew2; } private static String compressNumber(long number, int shift) { char[] buf = new char[62]; int charPos = 62; int radix = 1 << shift; long mask = radix - 1; do { buf[--charPos] = digits[(int) (number & mask)]; number >>>= shift; } while (number != 0); return new String(buf, charPos, (62 - charPos)); } }