Class AbstractDateAdapter

java.lang.Object
javax.xml.bind.annotation.adapters.XmlAdapter<String,Date>
org.cruk.clarity.api.jaxb.AbstractDateAdapter
Direct Known Subclasses:
LongTimestampAdapter, ShortDateAdapter

public abstract class AbstractDateAdapter extends javax.xml.bind.annotation.adapters.XmlAdapter<String,Date>
Base for date adapters. Uses a thread local to keep thread safe with the thread unsafe DateFormat objects.
  • Constructor Details

    • AbstractDateAdapter

      protected AbstractDateAdapter()
      Empty constructor.
  • Method Details

    • createFormatter

      protected abstract DateFormat createFormatter()
      Create the correct date format object for the type of dates expected.
      Returns:
      The DateFormat object.
    • unmarshal

      public Date unmarshal(String v) throws ParseException
      Parse the string into a Date object.
      Specified by:
      unmarshal in class javax.xml.bind.annotation.adapters.XmlAdapter<String,Date>
      Parameters:
      v - The string to parse.
      Returns:
      A Date object for the string, or null if v is null.
      Throws:
      ParseException - if the string cannot be parsed.
    • marshal

      public String marshal(Date v)
      Convert the given date into the expected date format.
      Specified by:
      marshal in class javax.xml.bind.annotation.adapters.XmlAdapter<String,Date>
      Parameters:
      v - The date to print.
      Returns:
      The string version of the date, or null if v is null.