Here you can find the source of long2sortableStr(long val)
public static String long2sortableStr(long val)
//package com.java2s; //License from project: Apache License public class Main { public static String long2sortableStr(long val) { char[] arr = new char[5]; long2sortableStr(val, arr, 0); return new String(arr, 0, 5); }//from ww w . j av a 2 s .c om public static String long2sortableStr(String val) { return long2sortableStr(Long.parseLong(val)); } public static int long2sortableStr(long val, char[] out, int offset) { val += Long.MIN_VALUE; out[offset++] = (char) (val >>> 60); out[offset++] = (char) (val >>> 45 & 0x7fff); out[offset++] = (char) (val >>> 30 & 0x7fff); out[offset++] = (char) (val >>> 15 & 0x7fff); out[offset] = (char) (val & 0x7fff); return 5; } }