That's what I'm doing:
public static final TimeZone UTC; // 0001.01.01 12:00:00 AM +0000 public static final Date BEGINNING_OF_TIME; // new Date(Long.MAX_VALUE) in UTC time zone public static final Date END_OF_TIME; static { UTC = TimeZone.getTimeZone("UTC"); final Calendar c = new GregorianCalendar(UTC); c.set(1, 0, 1, 0, 0, 0); c.set(Calendar.MILLISECOND, 0); BEGINNING_OF_TIME = c.getTime(); c.setTime(new Date(Long.MAX_VALUE)); END_OF_TIME = c.getTime(); }
Please note that if TimeZone is NOT UTC, you will get an offset from the "end of time" that will not be maximum. They are especially useful for inserting into database fields and the absence of null dates.
user177800 Nov 16 '09 at 20:30 2009-11-16 20:30
source share