XMLDateTimeUtil Class

com.bea.p13n.xml.schema
XMLDateTimeUtil Class

public class XMLDateTimeUtil

    extends Object

ISO8601 date utility. This class will read and write the correct ISO standard date, time, and timeInstant tags


Hierarchy
Object
  XMLDateTimeUtil

Constructor Summary

XMLDateTimeUtil()

Default constructor.
 

Method Summary

public static String
formatDate(Date aDate)
Format a date in ISO standard.
public static String
formatDate(Calendar aDate)
public static String
formatTime(Date aTime)
Format a time in ISO standard.
public static String
formatTime(Calendar aTime)
public static String
formatTimeInstant(Date aDateTime)
Format a date-time in ISO standard.
public static String
formatTimeInstant(Calendar aDateTime)
public static String
getOffset(Calendar calendar)
Create a string representing the offset for the date being formatted.
protected static StringBuffer
jdk14CompliantString(StringBuffer sb)
The dates we use are ISO8601 compliant, but jdk does not understand that, so we return a string buffer that understand jdk1.4 format.
public static void
main(String[] args)
public static Calendar
readDate(String aDate)
public static Date
readDateAsDate(String aDate)
Parse the xml string back into a Date.
public static Calendar
readTime(String aTime)
public static Date
readTimeAsDate(String aTime)
Parse the time back into a Date.
public static Calendar
readTimeInstant(String aDateTime)
public static Date
readTimeInstantAsDate(String aDateTime)
Parse the date time back into a Date.
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   

Constructor Detail

XMLDateTimeUtil

public XMLDateTimeUtil()
Default constructor.
 

Method Detail

formatDate(Date) Method

public static String formatDate(Date aDate)
Format a date in ISO standard.

Returns

correctly formatted string.

formatDate(Calendar) Method

public static String formatDate(Calendar aDate)

formatTime(Date) Method

public static String formatTime(Date aTime)
Format a time in ISO standard.

Returns

correctly formatted string.

formatTime(Calendar) Method

public static String formatTime(Calendar aTime)

formatTimeInstant(Date) Method

public static String formatTimeInstant(Date aDateTime)
Format a date-time in ISO standard.

Returns

correctly formatted string.

formatTimeInstant(Calendar) Method

public static String formatTimeInstant(Calendar aDateTime)

getOffset(Calendar) Method

public static String getOffset(Calendar calendar)
Create a string representing the offset for the date being formatted. The reason this needs to be called when the date is created, rather than set in a static manner, is that when someone creates a date for a time of year with a different savings/standard time than the current time, the offset needs to be correct. So this method returns the correct offset for the date being created.


jdk14CompliantString(StringBuffer) Method

protected static StringBuffer jdk14CompliantString(StringBuffer sb)
The dates we use are ISO8601 compliant, but jdk does not understand that, so we return a string buffer that understand jdk1.4 format. Essentially what it does is that it removes the ':' in the timezone


main(String[]) Method

public static void main(String[] args)

readDate(String) Method

public static Calendar readDate(String aDate)

readDateAsDate(String) Method

public static Date readDateAsDate(String aDate)
Parse the xml string back into a Date.


readTime(String) Method

public static Calendar readTime(String aTime)

readTimeAsDate(String) Method

public static Date readTimeAsDate(String aTime)
Parse the time back into a Date. This method uses the current date as the date to accompany the time string, so that the Date object returned will have the correct standard-vs-savings time offset. If you just format a time string with no date, you get that time on 1 January 1970, which will cause the time offset to be wrong during daylight-savings time.


readTimeInstant(String) Method

public static Calendar readTimeInstant(String aDateTime)

readTimeInstantAsDate(String) Method

public static Date readTimeInstantAsDate(String aDateTime)
Parse the date time back into a Date.