fork(2) 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. import java.time.zone.ZoneRules;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. int year = 1947;
  16. int month = 2;
  17. int day = 23;
  18. LocalDate localDate = LocalDate.of( year , month , day );
  19.  
  20. LocalTime beforeJump = LocalTime.of( 1 , 0 );
  21. LocalTime afterJump = LocalTime.of( 4 , 0 );
  22.  
  23. ZoneId z = ZoneId.of( "Europe/Prague" );
  24.  
  25. ZonedDateTime zdtBeforeJump = ZonedDateTime.of( localDate , beforeJump , z );
  26. ZonedDateTime zdtAfterJump = ZonedDateTime.of( localDate , afterJump , z );
  27.  
  28. System.out.println( "zdtBeforeJump.toString() = " + zdtBeforeJump );
  29. System.out.println( "zdtAfterJump.toString() = " + zdtAfterJump );
  30.  
  31. ZoneRules rules = z.getRules();
  32. ZoneOffset offsetBeforeJump = rules.getOffset( zdtBeforeJump.toInstant() );
  33. ZoneOffset offsetAfterJump = rules.getOffset( zdtAfterJump.toInstant() );
  34.  
  35. System.out.println( "offsetBeforeJump.toString() = " + offsetBeforeJump );
  36. System.out.println( "offsetAfterJump.toString() = " + offsetAfterJump );
  37. }
  38. }
Success #stdin #stdout 0.16s 38584KB
stdin
Standard input is empty
stdout
zdtBeforeJump.toString() = 1947-02-23T01:00Z[Europe/Prague]
zdtAfterJump.toString() = 1947-02-23T04:00+01:00[Europe/Prague]
offsetBeforeJump.toString() = Z
offsetAfterJump.toString() = +01:00