Skip to content

Instantly share code, notes, and snippets.

@noctarius
Created September 1, 2016 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noctarius/c010214c0852358de54950eda1682ada to your computer and use it in GitHub Desktop.
Save noctarius/c010214c0852358de54950eda1682ada to your computer and use it in GitHub Desktop.
@Test
public void test_exception_flow_control() {
Calendar calendar = Calendar.getInstance();
calendar.set(2003, 11, 13, 18, 30, 02);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
calendar.set(Calendar.MILLISECOND, 250);
Instant expected = calendar.toInstant();
ZoneId UTC = ZoneId.of("UTC");
DateTimeFormatter fractionFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.US);
String date = "2003-12-13T18:30:02.25+01:00";
Instant actual = LocalDateTime.parse(date, fractionFormat).atZone(UTC).toInstant();
assertEquals(expected, actual);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment