com.timeindexing.time
Class DateFormatter

java.lang.Object
  extended bycom.timeindexing.time.DateFormatter

public class DateFormatter
extends java.lang.Object

A Date formatter that displays times and dates reltive to GMT. The date formatting required here is not interested in TimeZones, but the java.text.SimpleDateFormat has no mechanism for specifying a TimeZone; it uses the default one of the app.

This is a hack to get around this. It sets the TimeZone to GMT, allocates a SimpleDateFormat, and then resets the TimeZone back to the default. The problem is that another thread may need the default TimeZone whilst this is happening. To overcome this we synchronize on TimeZone.class. All very nasty.


Constructor Summary
protected DateFormatter(java.lang.String pattern)
          Construct a DateFormatter.
 
Method Summary
 java.lang.String format(java.util.Date date)
          Formats a Date into a date/time string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatter

protected DateFormatter(java.lang.String pattern)
Construct a DateFormatter.

Method Detail

format

public java.lang.String format(java.util.Date date)
Formats a Date into a date/time string.

Parameters:
date - the time value to be formatted into a time string.
Returns:
the formatted time string.