Class DatatypeUtils

java.lang.Object
fr.opensagres.xdocreport.core.utils.DatatypeUtils

public class DatatypeUtils extends Object
  • Constructor Details

    • DatatypeUtils

      public DatatypeUtils()
  • Method Details

    • formatAsXSDateTime

      public static String formatAsXSDateTime(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".

      Specific target lexical representation format is determined by #getXMLSchemaType().

      Returns:
      XML, as String, representation of this XMLGregorianCalendar
      Throws:
      IllegalStateException - if the combination of set fields does not match one of the eight defined XML Schema builtin date/time datatypes.
    • parseXSDateTime

      public static Date parseXSDateTime(String lexicalRepresentation)

      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:
      XMLGregorianCalendar created from the lexicalRepresentation.
      Throws:
      IllegalArgumentException - If the lexicalRepresentation is not a valid XMLGregorianCalendar.
      NullPointerException - If lexicalRepresentation is null.