Class XMLAdapter<S,​T>

java.lang.Object
net.time4j.TemporalType<S,​T>
net.time4j.xml.XMLAdapter<S,​T>
Type Parameters:
S - source type in XML-Java
T - target type in Time4J
All Implemented Interfaces:
Converter<S,​T>

public abstract class XMLAdapter<S,​T> extends TemporalType<S,​T>

Serves as bridge to temporal types in XML-related Java.

All singleton instances are defined as static constants and are immutable.

Since:
3.0
Author:
Meno Hochschild
  • Field Details

    • XML_DATE

      public static final XMLAdapter<XMLGregorianCalendar,​PlainDate> XML_DATE

      Bridge between a XML-date according to xsd:date and the type PlainDate.

      Example:

        XMLGregorianCalendar xmlGregCal =
            DatatypeFactory.newInstance().newXMLGregorianCalendarDate(
                2014, 2, 28, 60); // here with optional offset
        PlainDate date = XMLAdapter.XML_DATE.translate(xmlGregCal);
        System.out.println(date);
        // output: 2014-02-28
       
      Since:
      3.0
    • XML_TIME

      public static final XMLAdapter<XMLGregorianCalendar,​PlainTime> XML_TIME

      Bridge between a XML-time according to xsd:time and the type PlainTime.

      Example:

        XMLGregorianCalendar xmlGregCal =
            DatatypeFactory.newInstance().newXMLGregorianCalendarTime(
                21, 45, 30, 0, 60); // here with optional offset
        PlainTime time = XMLAdapter.XML_TIME.translate(xmlGregCal);
        System.out.println(time);
        // output: T21:45:30
       

      Note: The special value T24:00 (midnight at end of day) is mapped to T00:00 in the value space of XMLGregorianCalendar.

      Since:
      3.0
    • XML_DATE_TIME

      public static final XMLAdapter<XMLGregorianCalendar,​PlainTimestamp> XML_DATE_TIME

      Bridge between a XML-timestamp according to xsd:dateTime (without timezone-offset) and the type PlainTimestamp.

      Example:

        XMLGregorianCalendar xmlGregCal =
            DatatypeFactory.newInstance().newXMLGregorianCalendar(
                2014, 2, 28, 14, 45, 30, 0, 60);
        PlainTimestamp tsp = XMLAdapter.XML_DATE_TIME.translate(xmlGregCal);
        System.out.println(tsp);
        // output: 2014-02-28T14:45:30
       
      Since:
      3.0
    • XML_DATE_TIME_OFFSET

      public static final XMLAdapter<XMLGregorianCalendar,​ZonalDateTime> XML_DATE_TIME_OFFSET

      Bridge between a XML-timestamp according to xsd:dateTime inclusive timezone-offset and the type ZonalDateTime.

      Example:

        XMLGregorianCalendar xmlGregCal =
            DatatypeFactory.newInstance().newXMLGregorianCalendar(
                2014, 2, 28, 14, 45, 30, 0, 60);
        ZonalDateTime zdt = XMLAdapter.XML_DATE_TIME_OFFSET.translate(xmlGregCal);
        System.out.println(zdt.print(Iso8601Format.EXTENDED_DATE_TIME_OFFSET));
        // output: 2014-02-28T14:45:30+01:00
       
      Since:
      3.0
    • XML_DURATION

      public static final XMLAdapter<Duration,​Duration<IsoUnit>> XML_DURATION

      Bridge between a XML-duration according to xsd:duration and the Time4J-type Duration.

      Since:
      3.0