org.deckfour.xes.util
Class XsDateTimeConversion

java.lang.Object
  extended by org.deckfour.xes.util.XsDateTimeConversion

public class XsDateTimeConversion
extends Object

This class serves as a provider for static xs:dateTime-related manipulation and parsing methods. Note that this class should not be static, as access to SimpleDateFormat needs to be synchronized and hence multiple threads would be holding onto each other.

Author:
Christian W. Guenther (christian at deckfour dot org)

Field Summary
protected  GregorianCalendar cal
          Calendar instance used for calculating dates for timestamps
protected  SimpleDateFormat dfMillisTZone
          Date/Time parsing instance with milliseconds and time zone information.
protected static String XSDATETIME_FORMAT_STRING_MILLIS_TZONE
          Date/Time parsing format including milliseconds and time zone information.
protected  Pattern xsDtPattern
          Pattern used for matching the XsDateTime formatted timestamp strings.
 
Constructor Summary
XsDateTimeConversion()
           
 
Method Summary
 String format(Date date)
          Formats a given date to the xs:dateTime format of XML.
 Date parseXsDateTime(String xsDateTime)
          Expects an XML xs:dateTime lexical format string, as in 2005-10-24T11:57:31.000+01:00.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XSDATETIME_FORMAT_STRING_MILLIS_TZONE

protected static final String XSDATETIME_FORMAT_STRING_MILLIS_TZONE
Date/Time parsing format including milliseconds and time zone information.

See Also:
Constant Field Values

dfMillisTZone

protected final SimpleDateFormat dfMillisTZone
Date/Time parsing instance with milliseconds and time zone information.


xsDtPattern

protected final Pattern xsDtPattern
Pattern used for matching the XsDateTime formatted timestamp strings.


cal

protected GregorianCalendar cal
Calendar instance used for calculating dates for timestamps

Constructor Detail

XsDateTimeConversion

public XsDateTimeConversion()
Method Detail

parseXsDateTime

public Date parseXsDateTime(String xsDateTime)
Expects an XML xs:dateTime lexical format string, as in 2005-10-24T11:57:31.000+01:00. Some bad MXML files miss timezone or milliseconds information, thus a certain amount of tolerance is applied towards malformed timestamp string representations. If unparseable, this method will return null.

Parameters:
xsDateTime - Timestamp string in the XML xs:dateTime format.
Returns:
Parsed Date object.

format

public String format(Date date)
Formats a given date to the xs:dateTime format of XML.

Parameters:
date - Date to be formatted.
Returns:
String formatting the given date.