com.bea.p13n.model
Class XmlDateTimeUtil

java.lang.Object
  extended by com.bea.p13n.model.XmlDateTimeUtil

public class XmlDateTimeUtil
extends Object

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


Constructor Summary
XmlDateTimeUtil()
          Default constructor.
 
Method Summary
static Calendar convert(Calendar xmlCal)
          Convert a Calendar from xbeans into a regular Calendar.
static String formatDate(Calendar aDate)
          Format a calendar instance in ISO8601 standard (yyyy-MM-ddZ).
static String formatDate(Date aDate)
          Format a date in ISO8601 standard (yyyy-MM-ddZ).
static String formatTime(Calendar aTime)
          Format a time in ISO8601 standard (HH:mm:ssZ) without the fractions of a second portion.
static String formatTime(Calendar aTime, boolean includeFraction)
          Format a time in ISO8601 standard (HH:mm:ss(.fff)?Z).
static String formatTime(Date aTime)
          Format a time in ISO8601 standard (HH:mm:ss?Z) without the fractions of a second portion.
static String formatTime(Date aTime, boolean includeFraction)
          Format a time in ISO8601 standard (HH:mm:ss(.fff)?Z).
static String formatTimeInstant(Calendar aDateTime)
          Format a date-time in ISO8601 standard (yyyy-MM-ddTHH:mm:ssZ).
static String formatTimeInstant(Calendar aDateTime, boolean includeFraction)
          Format a date-time in ISO8601 standard (yyyy-MM-ddTHH:mm:ss(.fff)?Z).
static String formatTimeInstant(Date aDateTime)
          Format a date-time in ISO8601 standard (yyyy-MM-ddTHH:mm:ssZ).
static String formatTimeInstant(Date aDateTime, boolean includeFraction)
          Format a date-time in ISO8601 standard (yyyy-MM-ddTHH:mm:ss(.fff)?Z).
static Calendar readDate(String aDate)
          Parse the IS08601 date string (yyyy-MM-ddZ) into a calendar instance.
static Date readDateAsDate(String aDate)
          Parse the IS08601 date string (yyyy-MM-ddZ) into a Date.
static Calendar readTime(String aTime)
          Parse the ISO8601 formatted time into a calendar.
static Date readTimeAsDate(String aTime)
          Parse the ISO8601 formatted time into a Date.
static Calendar readTimeInstant(String aDateTime)
          Parse the ISO8601 formatted timeInstant string into a calendar.
static Date readTimeInstantAsDate(String aDateTime)
          Parse the ISO8601 formatted timeInstant string into a Date.
 
Methods inherited 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

public static String formatDate(Date aDate)
Format a date in ISO8601 standard (yyyy-MM-ddZ).

Parameters
aDate - the date to format
Returns
correctly formatted string.

formatDate

public static String formatDate(Calendar aDate)
Format a calendar instance in ISO8601 standard (yyyy-MM-ddZ).

Parameters
aDate - the calendar to format.
Returns
correctly formatted string.

readDateAsDate

public static Date readDateAsDate(String aDate)
Parse the IS08601 date string (yyyy-MM-ddZ) into a Date.

Parameters
aDate - the date string.
Throws
IllegalArgumentException - on invalid string.

readDate

public static Calendar readDate(String aDate)
Parse the IS08601 date string (yyyy-MM-ddZ) into a calendar instance.

Parameters
aDate - the date string.
Throws
IllegalArgumentException - on invalid string.

formatTime

public static String formatTime(Date aTime,
                                boolean includeFraction)
Format a time in ISO8601 standard (HH:mm:ss(.fff)?Z).

Parameters
aTime - the date contained the time to format.
includeFraction - true to include the fractions of a second (.fff) portion in the results, false to not.
Returns
correctly formatted string.

formatTime

public static String formatTime(Date aTime)
Format a time in ISO8601 standard (HH:mm:ss?Z) without the fractions of a second portion.

Parameters
aTime - the date containing the time to format.
Returns
correctly formatted string.

formatTime

public static String formatTime(Calendar aTime,
                                boolean includeFraction)
Format a time in ISO8601 standard (HH:mm:ss(.fff)?Z).

Parameters
aTime - the calendar containing the time to format.
includeFraction - true to include the fractions of a second (.fff) portion in the results, false to not.
Returns
correctly formatted string.

formatTime

public static String formatTime(Calendar aTime)
Format a time in ISO8601 standard (HH:mm:ssZ) without the fractions of a second portion.

Parameters
aTime - the calendar containing the time to format.
Returns
correctly formatted string.

readTimeAsDate

public static Date readTimeAsDate(String aTime)
Parse the ISO8601 formatted time into a Date.

Throws
IllegalArgumentException - on invalid string.
See Also
readTime(java.lang.String)

readTime

public static Calendar readTime(String aTime)
Parse the ISO8601 formatted time into a calendar. 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.

Throws
IllegalArgumentException - on invalid string.

formatTimeInstant

public static String formatTimeInstant(Date aDateTime,
                                       boolean includeFraction)
Format a date-time in ISO8601 standard (yyyy-MM-ddTHH:mm:ss(.fff)?Z).

Parameters
aDateTime - the date with the date and time.
includeFraction - true to include the fractions of a second (.fff) portion in the results, false to not.
Returns
correctly formatted string.

formatTimeInstant

public static String formatTimeInstant(Date aDateTime)
Format a date-time in ISO8601 standard (yyyy-MM-ddTHH:mm:ssZ).

Parameters
aDateTime - the date with the date and time.
Returns
correctly formatted string.

formatTimeInstant

public static String formatTimeInstant(Calendar aDateTime,
                                       boolean includeFraction)
Format a date-time in ISO8601 standard (yyyy-MM-ddTHH:mm:ss(.fff)?Z).

Parameters
aDateTime - the calendar with the date and time.
includeFraction - true to include the fractions of a second (.fff) portion in the results, false to not.
Returns
correctly formatted string.

formatTimeInstant

public static String formatTimeInstant(Calendar aDateTime)
Format a date-time in ISO8601 standard (yyyy-MM-ddTHH:mm:ssZ).

Parameters
aDateTime - the calendar with the date and time.
Returns
correctly formatted string.

readTimeInstantAsDate

public static Date readTimeInstantAsDate(String aDateTime)
Parse the ISO8601 formatted timeInstant string into a Date.

Parameters
aDateTime - the formatted string.
Throws
IllegalArgumentException - on invalid string.

readTimeInstant

public static Calendar readTimeInstant(String aDateTime)
Parse the ISO8601 formatted timeInstant string into a calendar.

Parameters
aDateTime - the formatted string.
Throws
IllegalArgumentException - on invalid string.

convert

public static final Calendar convert(Calendar xmlCal)
Convert a Calendar from xbeans into a regular Calendar. Calendar.equals() doesn't work against XmlCalendars, so just convert them.



Copyright © 2011, Oracle. All rights reserved.