@Test(expected = DateTimeParseException.class) public void testUnmarshalWithInvalidString() throws Exception { new ZonedDateTimeAdapter().unmarshal("ivalid string"); }
@Override public ZonedDateTime unmarshal(String value) throws Exception { if (value == null) { return null; } if (value.matches(".*([Z]|[+-][0-9]{1,2}:[0-9]{1,2})$")) { return ZonedDateTime.parse(value).withZoneSameInstant(ZoneOffset.UTC); } else { LocalDateTime local = LocalDateTime.parse(value, localFormat); ZonedDateTime localZ = ZonedDateTime.of(local, getZoneId()); return localZ.withZoneSameInstant(ZoneOffset.UTC); } }
ZonedDateTimeAdapter extends XmlAdapter<String, ZonedDateTime> { @Override public ZonedDateTime unmarshal(String value) throws Exception { if (value == null) { return null; } if (value.matches(".*([Z]|[+-][0-9]{1,2}:[0-9]{1,2})$")) { return ZonedDateTime.parse(value).withZoneSameInstant(ZoneOffset.UTC); } else { LocalDateTime local = LocalDateTime.parse(value, localFormat); ZonedDateTime localZ = ZonedDateTime.of(local, getZoneId()); return localZ.withZoneSameInstant(ZoneOffset.UTC); } } }
ZonedDateTimeAdapter extends XmlAdapter<String, ZonedDateTime> { @Override public ZonedDateTime unmarshal(String value) throws Exception { if (value == null) { return null; } if (value.matches(".*([Z]|[+-][0-9]{1,2}:[0-9]{1,2})$")) { return ZonedDateTime.parse(value).withZoneSameInstant(ZoneOffset.UTC); } else { LocalDateTime local = LocalDateTime.parse(value, localFormat); ZonedDateTime localZ = ZonedDateTime.of(local, getZoneId()); return localZ.withZoneSameInstant(ZoneOffset.UTC); } }  }
ZonedDateTimeAdapter extends XmlAdapter<String, ZonedDateTime> { @Override public ZonedDateTime unmarshal(String value) throws Exception { if (value == null) { return null; } if (value.matches(".*([Z]|[+-][0-9]{1,2}:[0-9]{1,2})$")) { return ZonedDateTime.parse(value).withZoneSameInstant(ZoneOffset.UTC); } else { LocalDateTime local = LocalDateTime.parse(value, localFormat); ZonedDateTime localZ = ZonedDateTime.of(local, getZoneId()); return localZ.withZoneSameInstant(ZoneOffset.UTC); } }  static ZoneId getZoneId(); static ZoneId setZoneId(ZoneId zoneId); @Override ZonedDateTime unmarshal(String value); @Override String marshal(ZonedDateTime value); }
ZonedDateTimeAdapter extends XmlAdapter<String, ZonedDateTime> { @Override public ZonedDateTime unmarshal(String value) throws Exception { if (value == null) { return null; } if (value.matches(".*([Z]|[+-][0-9]{1,2}:[0-9]{1,2})$")) { return ZonedDateTime.parse(value).withZoneSameInstant(ZoneOffset.UTC); } else { LocalDateTime local = LocalDateTime.parse(value, localFormat); ZonedDateTime localZ = ZonedDateTime.of(local, getZoneId()); return localZ.withZoneSameInstant(ZoneOffset.UTC); } }  static ZoneId getZoneId(); static ZoneId setZoneId(ZoneId zoneId); @Override ZonedDateTime unmarshal(String value); @Override String marshal(ZonedDateTime value);  }