Class DurationAdapter

java.lang.Object
javax.xml.bind.annotation.adapters.XmlAdapter<String,Duration>
org.somda.sdc.common.util.DurationAdapter

public class DurationAdapter extends javax.xml.bind.annotation.adapters.XmlAdapter<String,Duration>
Adapter class to convert XSD durations to Java durations and vice versa.

This adapter was added because the native use of Duration does not work with all ISO 8601 formats. Duration only accepts PnDTnHnMn.nS, whereas this adapter accepts PnYnMnWnDTnHnMn.nS.

Important note: the duration parser ignores years, months and weeks.

  • Constructor Details

    • DurationAdapter

      public DurationAdapter()
  • Method Details

    • unmarshal

      public Duration unmarshal(String v)
      Specified by:
      unmarshal in class javax.xml.bind.annotation.adapters.XmlAdapter<String,Duration>
    • marshal

      public String marshal(Duration v)
      Specified by:
      marshal in class javax.xml.bind.annotation.adapters.XmlAdapter<String,Duration>