org.erights.e.develop.format
Class ETimeFormat

java.lang.Object
  |
  +--org.erights.e.develop.format.ETimeFormat

public class ETimeFormat
extends Object

Untamed: Just converts back and forth between milliseconds since the epoch (standard binary time representation) and ISO8601/UTC (standard sortable textual respresentation) but enhanced to represent milliseconds.

Author:
Mark S. Miller
See Also:
w3c's explanation of , html4.0's explanation

Field Summary
private static java.text.DateFormat SortableFormat
           
 
Constructor Summary
ETimeFormat()
          Enabled:
 
Method Summary
static String formatTime(long absMillis)
          Enabled: Shows absMillis (since epoch) as a sortable absolute date/time string that can be included in a single URI field (no "#"s or "/"s).
static long parseTime(String sortableTime)
          Enabled: Given a sortableTime string in the format returned by millisToDate, return the corresponding number of seconds since the epoch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SortableFormat

private static final java.text.DateFormat SortableFormat
Constructor Detail

ETimeFormat

public ETimeFormat()
Enabled:

Method Detail

formatTime

public static String formatTime(long absMillis)
Enabled: Shows absMillis (since epoch) as a sortable absolute date/time string that can be included in a single URI field (no "#"s or "/"s).

The format must also be independent of Locale, the default current TimeZone, or the current time. In the terminology of ISO601, the actual format is "YYYY-MM-DDThh:mm:ss.sssTZD", where the value of TZD (timezone) is "Z", indicating UTC (Universal Standard Time, which is just another name for GMT).

It would be good if the format returned could also be used within filenames, but unfortunately this conflicts with the familiar use of colon (":") to represent clock time, as mandated by ISO8601. Clients (such as the Trace system) that need to embed the result in a filename should do a .replace(':','_'). parseTime(String) will handle either colons or underbars in its input.


parseTime

public static long parseTime(String sortableTime)
                      throws java.text.ParseException
Enabled: Given a sortableTime string in the format returned by millisToDate, return the corresponding number of seconds since the epoch.

java.text.ParseException


comments?