Methods Summary |
---|
public static java.lang.String | MAX_DATE_STRING()
char[] buffer = new char[DATE_LEN];
char c = Character.forDigit(Character.MAX_RADIX-1, Character.MAX_RADIX);
for (int i = 0 ; i < DATE_LEN; i++)
buffer[i] = c;
return new String(buffer);
|
public static java.lang.String | MIN_DATE_STRING()
return timeToString(0);
|
public static java.lang.String | dateToString(java.util.Date date)Converts a Date to a string suitable for indexing.
return timeToString(date.getTime());
|
public static java.util.Date | stringToDate(java.lang.String s)Converts a string-encoded date into a Date object.
return new Date(stringToTime(s));
|
public static long | stringToTime(java.lang.String s)Converts a string-encoded date into a millisecond time.
return Long.parseLong(s, Character.MAX_RADIX);
|
public static java.lang.String | timeToString(long time)Converts a millisecond time to a string suitable for indexing.
if (time < 0)
throw new RuntimeException("time '" + time + "' is too early, must be >= 0");
String s = Long.toString(time, Character.MAX_RADIX);
if (s.length() > DATE_LEN)
throw new RuntimeException("time '" + time + "' is too late, length of string " +
"representation must be <= " + DATE_LEN);
// Pad with leading zeros
if (s.length() < DATE_LEN) {
StringBuffer sb = new StringBuffer(s);
while (sb.length() < DATE_LEN)
sb.insert(0, 0);
s = sb.toString();
}
return s;
|