fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.time.* ;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. LocalDate tomorrow = LocalDate.now( ZoneOffset.UTC ).plusDays( 1 ) ;
  15. LocalTime eightPM = LocalTime.of( 20 , 0 ) ;
  16. OffsetDateTime odt = OffsetDateTime.of( tomorrow , eightPM , ZoneOffset.UTC ) ;
  17.  
  18. ZoneId z = ZoneId.of( "Europe/Berlin" ) ;
  19. ZonedDateTime zdt = odt.atZoneSameInstant( z ) ;
  20.  
  21. System.out.println( "odt.toString(): " + odt ) ;
  22. System.out.println( "zdt.toString(): " + zdt ) ;
  23. }
  24. }
Success #stdin #stdout 0.13s 38256KB
stdin
Standard input is empty
stdout
odt.toString(): 2021-02-17T20:00Z
zdt.toString(): 2021-02-17T21:00+01:00[Europe/Berlin]