Advertisement
DulcetAirman

JAX-Adapter for OffsetDateTime

Jun 27th, 2015
270
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class OffsetDateTimeAdapter extends XmlAdapter<String, OffsetDateTime> {
  2.  
  3.   @Override
  4.   public OffsetDateTime unmarshal(final String iso8601) throws Exception {
  5.     if (iso8601 == null || iso8601.isEmpty()) {
  6.       return null;
  7.     }
  8.     return OffsetDateTime.parse(iso8601);
  9.   }
  10.  
  11.   @Override
  12.   public String marshal(final OffsetDateTime odt) throws Exception {
  13.     if (odt == null) {
  14.       return null;
  15.     }
  16.     return odt.toString(); // ISO-8601-Format
  17.   }
  18. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement