fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.time.* ;
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. //LocalDate date = LocalDate.of(2017,Month.FEBRUARY,3);
  13. LocalDate date = LocalDate.now();
  14. ZoneId zoneId = ZoneId.of("Europe/Brussels");
  15. LocalDateTime ldt = LocalDateTime.now();
  16.  
  17. OffsetDateTime odt2 = ldt.atZone(zoneId).toOffsetDateTime();
  18. // Converts to ZonedDateTime (date + time + zone) then to OffsetDateTime
  19. OffsetDateTime odt = date.atStartOfDay(zoneId).toOffsetDateTime();
  20. System.out.println( date ) ;
  21. System.out.println( zoneId ) ;
  22. System.out.println( odt ) ;
  23. System.out.println( ldt ) ;
  24. System.out.println( odt2 ) ;
  25. }
  26.  
  27. }
Success #stdin #stdout 0.18s 60260KB
stdin
Standard input is empty
stdout
2026-03-31
Europe/Brussels
2026-03-31T00:00+02:00
2026-03-31T08:19:11.357360
2026-03-31T08:19:11.357360+02:00