Advertisement
DulcetAirman

JAX-Adapter for OffsetDateTime

Jun 27th, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment
Advertisement