Class DatatypeUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatAsXSDateTime(Date date) Return the lexical representation of the given Date The format is specified in XML Schema 1.0 Part 2, Section 3.2.[7-14].1, Lexical Representation".static DateparseXSDateTime(String lexicalRepresentation) Create a new Date by parsing the String as a lexical representation.
-
Constructor Details
-
DatatypeUtils
public DatatypeUtils()
-
-
Method Details
-
formatAsXSDateTime
Return the lexical representation of the given Date The format is specified in XML Schema 1.0 Part 2, Section 3.2.[7-14].1, Lexical Representation".
Specific target lexical representation format is determined by
#getXMLSchemaType().- Returns:
- XML, as
String, representation of thisXMLGregorianCalendar - Throws:
IllegalStateException- if the combination of set fields does not match one of the eight defined XML Schema builtin date/time datatypes.
-
parseXSDateTime
Create a new Date by parsing the String as a lexical representation.
Parsing the lexical string representation is defined in XML Schema 1.0 Part 2, Section 3.2.[7-14].1, Lexical Representation.
The string representation may not have any leading and trailing whitespaces.
The parsing is done field by field so that the following holds for any lexically correct String x:
newXMLGregorianCalendar( x ).toXMLFormat().equals( x )
Except for the noted lexical/canonical representation mismatches listed in XML Schema 1.0 errata, Section 3.2.7.2.
- Parameters:
lexicalRepresentation- Lexical representation of one the eight XML Schema date/time datatypes.- Returns:
XMLGregorianCalendarcreated from thelexicalRepresentation.- Throws:
IllegalArgumentException- If thelexicalRepresentationis not a validXMLGregorianCalendar.NullPointerException- IflexicalRepresentationisnull.
-