Package org.jibx.runtime
Class JodaConvert
- java.lang.Object
-
- org.jibx.runtime.JodaConvert
-
public abstract class JodaConvert extends Object
Utility class supplying static methods for Joda date/time conversions. The actual serializer/deserializer methods are all public so that they'll be included in JavaDocs; support methods are protected, so that they'll be exposed for user classes extending this class.- Author:
- Dennis M. Sosnoski
-
-
Constructor Summary
Constructors Constructor Description JodaConvert()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static org.joda.time.DateMidnightdeserializeDateMidnight(String text, org.joda.time.DateTimeZone zone)Deserialize date value as a midnight date in the specified time zone.static org.joda.time.LocalDatedeserializeLocalDate(String text)Deserialize date value from text as local date without time zone.static org.joda.time.DateMidnightdeserializeLocalDateMidnight(String text)Deserialize date value from text as midnight date in default (local) time zone.static org.joda.time.DateTimedeserializeLocalDateTime(String text)Deserialize date/time value from text into the local (default) time zone.static org.joda.time.LocalTimedeserializeLocalTime(String text)Deserialize time value from text as local time.static org.joda.time.DateTimedeserializeStrictLocalDateTime(String text)Deserialize local (default zone) date/time value from text with time zone required.static org.joda.time.DateTimedeserializeStrictUTCDateTime(String text)Deserialize UTC date/time value from text with time zone required.static org.joda.time.DateMidnightdeserializeUTCDateMidnight(String text)Deserialize date value from text as midnight date in UTC time zone.static org.joda.time.DateTimedeserializeUTCDateTime(String text)Deserialize UTC date/time value from text into the UTC time zone.static org.joda.time.DateMidnightdeserializeZonedDateMidnight(String text)Deserialize date value from text as midnight date in specified (or default) time zone.static org.joda.time.DateTimedeserializeZonedDateTime(String text)Deserialize date/time value from text in specified (or default) time zone.protected static org.joda.time.DateTimeZonefindZone(String text, org.joda.time.DateTimeZone dflt)Find the date/time zone for an xs:date or xs:dateTime text representation.protected static org.joda.time.DateTimeparseDateTime(String text, boolean full, org.joda.time.DateTimeZone zone)Parse date/time value from text.static StringserializeLocalDate(org.joda.time.LocalDate date)Serialize local date value to general date text without time zone.static StringserializeUnzonedDateMidnight(org.joda.time.DateMidnight date)Serialize midnight date value to general date text without time zone.static StringserializeUnzonedLocalTime(org.joda.time.LocalTime time)Serialize local time value to general date text without time zone.static StringserializeUTCDateMidnight(org.joda.time.DateMidnight date)Serialize midnight date value to general date text with UTC time zone.static StringserializeUTCDateTime(org.joda.time.DateTime time)Serialize date/time to general dateTime text.static StringserializeUTCLocalTime(org.joda.time.LocalTime time)Serialize local time value to general date text with UTC time zone.static StringserializeZonedDateMidnight(org.joda.time.DateMidnight date)Serialize midnight date value to general date text with time zone offset.static StringserializeZonedDateTime(org.joda.time.DateTime time)Serialize date/time to general dateTime text.
-
-
-
Method Detail
-
deserializeLocalDate
public static org.joda.time.LocalDate deserializeLocalDate(String text) throws JiBXException
Deserialize date value from text as local date without time zone. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign and trailing time zone (with the time zone ignored in this case). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
serializeLocalDate
public static String serializeLocalDate(org.joda.time.LocalDate date)
Serialize local date value to general date text without time zone. Date/time values are formatted in W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign included if necessary.- Parameters:
date- date to be converted- Returns:
- converted date text
-
deserializeDateMidnight
protected static org.joda.time.DateMidnight deserializeDateMidnight(String text, org.joda.time.DateTimeZone zone) throws JiBXException
Deserialize date value as a midnight date in the specified time zone.- Parameters:
text- Date in textzone- Timezone- Returns:
- date
- Throws:
JiBXException- On conversion error
-
findZone
protected static org.joda.time.DateTimeZone findZone(String text, org.joda.time.DateTimeZone dflt) throws JiBXException
Find the date/time zone for an xs:date or xs:dateTime text representation.- Parameters:
text- xs:date or xs:dateTime valuedflt- default zone to be returned if no zone specified- Returns:
- zone Timezone
- Throws:
JiBXException- If error
-
deserializeZonedDateMidnight
public static org.joda.time.DateMidnight deserializeZonedDateMidnight(String text) throws JiBXException
Deserialize date value from text as midnight date in specified (or default) time zone. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign and trailing time zone. If the time zone indication is included a zone matching the offset is used for the date; otherwise the default time zone is used. This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
deserializeLocalDateMidnight
public static org.joda.time.DateMidnight deserializeLocalDateMidnight(String text) throws JiBXException
Deserialize date value from text as midnight date in default (local) time zone. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign and trailing time zone (with the time zone ignored in this case). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
deserializeUTCDateMidnight
public static org.joda.time.DateMidnight deserializeUTCDateMidnight(String text) throws JiBXException
Deserialize date value from text as midnight date in UTC time zone. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign and trailing time zone (with the time zone ignored in this case). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
serializeUnzonedDateMidnight
public static String serializeUnzonedDateMidnight(org.joda.time.DateMidnight date)
Serialize midnight date value to general date text without time zone. Date values are formatted in W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign included if necessary.- Parameters:
date- date to be converted- Returns:
- converted date text
-
serializeZonedDateMidnight
public static String serializeZonedDateMidnight(org.joda.time.DateMidnight date)
Serialize midnight date value to general date text with time zone offset. Date values are formatted in W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign included if necessary and trailing time zone offset.- Parameters:
date- date to be converted- Returns:
- converted date text
-
serializeUTCDateMidnight
public static String serializeUTCDateMidnight(org.joda.time.DateMidnight date)
Serialize midnight date value to general date text with UTC time zone. Date values are formatted in W3C XML Schema standard format as CCYY-MM-DDZ, with optional leading sign included if necessary.- Parameters:
date- date to be converted- Returns:
- converted date text
-
deserializeLocalTime
public static org.joda.time.LocalTime deserializeLocalTime(String text) throws JiBXException
Deserialize time value from text as local time. Time values are expected to match W3C XML Schema standard format as hh:mm:ss.fff, with optional trailing time zone (with the time zone ignored in this case). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
serializeUnzonedLocalTime
public static String serializeUnzonedLocalTime(org.joda.time.LocalTime time)
Serialize local time value to general date text without time zone. Time values are formatted in W3C XML Schema standard format as hh:mm:ss.fff.- Parameters:
time- time to be converted- Returns:
- converted time text
-
serializeUTCLocalTime
public static String serializeUTCLocalTime(org.joda.time.LocalTime time)
Serialize local time value to general date text with UTC time zone. Time values are formatted in W3C XML Schema standard format as hh:mm:ss.fffZ, with optional leading sign included if necessary.- Parameters:
time- time to be converted- Returns:
- converted time text
-
parseDateTime
protected static org.joda.time.DateTime parseDateTime(String text, boolean full, org.joda.time.DateTimeZone zone) throws JiBXException
Parse date/time value from text. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss.fff, with optional leading sign and trailing time zone (with the time zone used to convert the value to the target time zone). If the time zone is absent and not required the target time zone is assumed.- Parameters:
text- Date to parse from textfull- zoned time required flag (exception thrown if missing)zone- time zone used for returned date/time- Returns:
- converted date/time
- Throws:
JiBXException- If error
-
deserializeZonedDateTime
public static org.joda.time.DateTime deserializeZonedDateTime(String text) throws JiBXException
Deserialize date/time value from text in specified (or default) time zone. Date/time values are expected to match W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss.fff, with optional leading sign and trailing time zone. If the time zone indication is included a zone matching the offset is used for the date; otherwise the default time zone is used. This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
deserializeUTCDateTime
public static org.joda.time.DateTime deserializeUTCDateTime(String text) throws JiBXException
Deserialize UTC date/time value from text into the UTC time zone. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss.fff, with optional leading sign and trailing time zone (with the time zone used to convert the value to UTC, and UTC assumed if no time zone is specified). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
deserializeLocalDateTime
public static org.joda.time.DateTime deserializeLocalDateTime(String text) throws JiBXException
Deserialize date/time value from text into the local (default) time zone. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss.fff, with optional leading sign and trailing time zone (with the time zone used to convert the value to the local time zone, and the local time zone assumed if no time zone is specified). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
deserializeStrictUTCDateTime
public static org.joda.time.DateTime deserializeStrictUTCDateTime(String text) throws JiBXException
Deserialize UTC date/time value from text with time zone required. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss.fff, with optional leading sign but required trailing time zone (with the time zone used to convert the value to UTC). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
deserializeStrictLocalDateTime
public static org.joda.time.DateTime deserializeStrictLocalDateTime(String text) throws JiBXException
Deserialize local (default zone) date/time value from text with time zone required. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss.fff, with optional leading sign but required trailing time zone (with the time zone used to convert the value to the local time zone). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
serializeZonedDateTime
public static String serializeZonedDateTime(org.joda.time.DateTime time)
Serialize date/time to general dateTime text. Date/time values are formatted in W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss.fff, with optional leading sign included if necessary. Time zone information is always included in the output, with the value determined by the zone used for the date/time.- Parameters:
time- date/time to be converted- Returns:
- converted date/time text
-
serializeUTCDateTime
public static String serializeUTCDateTime(org.joda.time.DateTime time)
Serialize date/time to general dateTime text. Date/time values are formatted in W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss.fff, with optional leading sign included if necessary. Time zone information is always included in the output, as 'Z' to indicate UTC.- Parameters:
time- date/time to be converted- Returns:
- converted date/time text
-
-