Class ZuluOffsetDateTimeAdapter


  • public class ZuluOffsetDateTimeAdapter
    extends jakarta.xml.bind.annotation.adapters.XmlAdapter<java.lang.String,​java.time.OffsetDateTime>
    Zulu OffsetDateTime adapter for date time elements.

    Marshals the date time as a Zulu time with format YYYY-MM-DDThh:mm:ss[.sss]Z which is aligned with ISO 8601. Dislike the default jaxb implementation, this adapter will always print the Z The fractional seconds is printed only when it is different from zero.

    Notice the configured adapter in the model is the IsoDateTimeAdapter wrapper class, but you can pass this default implementation or your own in the constructor.

    Since:
    9.4,5
    See Also:
    TypeAdaptersConfiguration
    • Constructor Summary

      Constructors 
      Constructor Description
      ZuluOffsetDateTimeAdapter()
      Creates a date time adapter with the default format.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String marshal​(java.time.OffsetDateTime offsetDateTime)
      Formats an OffsetDateTime to a string using the configured format.
      java.lang.String toString()  
      java.time.OffsetDateTime unmarshal​(java.lang.String value)
      Parses a date-time string to create an OffsetDateTime object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ZuluOffsetDateTimeAdapter

        public ZuluOffsetDateTimeAdapter()
        Creates a date time adapter with the default format.
    • Method Detail

      • unmarshal

        public java.time.OffsetDateTime unmarshal​(java.lang.String value)
        Parses a date-time string to create an OffsetDateTime object.
        Specified by:
        unmarshal in class jakarta.xml.bind.annotation.adapters.XmlAdapter<java.lang.String,​java.time.OffsetDateTime>
        Parameters:
        value - the XML date time value to convert
        Returns:
        created OffsetDateTime object or null if it cannot be parsed
      • marshal

        public java.lang.String marshal​(java.time.OffsetDateTime offsetDateTime)
                                 throws java.lang.Exception
        Formats an OffsetDateTime to a string using the configured format.
        Specified by:
        marshal in class jakarta.xml.bind.annotation.adapters.XmlAdapter<java.lang.String,​java.time.OffsetDateTime>
        Parameters:
        offsetDateTime - the model OffsetDateTime to marshal
        Returns:
        formatted content for the XML
        Throws:
        java.lang.Exception
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object