fork download
  1. import java.time.LocalDate;
  2. import java.time.LocalTime;
  3. import java.time.ZoneId;
  4. import java.time.ZonedDateTime;
  5.  
  6. public class Main {
  7. public static void main(String[] args) {
  8. ZoneId zoneId = ZoneId.of("America/New_York");
  9.  
  10. // A sample ZonedDateTime during DST
  11. ZonedDateTime zdtDuringDST = ZonedDateTime.of(
  12. LocalDate.of(2024, 5, 20),
  13. LocalTime.MIN,
  14. zoneId
  15. );
  16.  
  17. // A sample ZonedDateTime outside DST
  18. ZonedDateTime zdtOutsideDST = ZonedDateTime.of(
  19. LocalDate.of(2024, 12, 20),
  20. LocalTime.MIN,
  21. zoneId
  22. );
  23.  
  24. System.out.println(zdtDuringDST);
  25. System.out.println(zdtOutsideDST);
  26. }
  27. }
  28.  
Success #stdin #stdout 0.14s 59296KB
stdin
Standard input is empty
stdout
2024-05-20T00:00-04:00[America/New_York]
2024-12-20T00:00-05:00[America/New_York]