org.deckfour.xes.util
Class XsDateTimeConversion

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

public class XsDateTimeConversion
extends java.lang.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  java.util.GregorianCalendar cal
          Calendar instance used for calculating dates for timestamps
protected  java.text.SimpleDateFormat dfMillisTZone
          Date/Time parsing instance with milliseconds and time zone information.
protected static java.lang.String XSDATETIME_FORMAT_STRING_MILLIS_TZONE
          Date/Time parsing format including milliseconds and time zone information.
protected  java.util.regex.Pattern xsDtPattern
          Pattern used for matching the XsDateTime formatted timestamp strings.
 
Constructor Summary
XsDateTimeConversion()
           
 
Method Summary
 java.lang.String format(java.util.Date date)
          Formats a given date to the xs:dateTime format of XML.
 java.util.Date parseXsDateTime(java.lang.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 java.lang.String XSDATETIME_FORMAT_STRING_MILLIS_TZONE
Date/Time parsing format including milliseconds and time zone information.

See Also:
Constant Field Values

dfMillisTZone

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


xsDtPattern

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


cal

protected java.util.GregorianCalendar cal
Calendar instance used for calculating dates for timestamps

Constructor Detail

XsDateTimeConversion

public XsDateTimeConversion()
Method Detail

parseXsDateTime

public java.util.Date parseXsDateTime(java.lang.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 java.lang.String format(java.util.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.