Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. String expected = "Mon Jul 01 2019 00:00:00 GMT-0500 (Central Daylight Time)";
  2. String format = "EEE MMM dd uuuu HH:mm:ss 'GMT'xx (zzzz)";
  3.  
  4. ZonedDateTime zdt = ZonedDateTime.of(2019, 7, 1, 0, 0, 0, 0, ZoneId.of("America/Chicago"));
  5. DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format);
  6.  
  7. System.out.println(zdt.format(dateTimeFormatter));
  8. System.out.println(expected);
  9.  
  10. System.out.println(ZonedDateTime.parse(expected, dateTimeFormatter));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement