fork(1) 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.format.* ;
  9. import java.time.temporal.* ;
  10. import java.time.chrono.* ;
  11. import java.time.zone.* ;
  12.  
  13.  
  14. /* Name of the class has to be "Main" only if the class is public. */
  15. class Ideone
  16. {
  17. public static void main (String[] args) throws java.lang.Exception
  18. {
  19. ZoneId z = ZoneId.of( "America/Santiago" );
  20. LocalDate ld = LocalDate.of( 2015 , Month.MARCH , 31 );
  21. LocalTime lt = LocalTime.of( 7 , 45 , 0 , 0 );
  22. ZonedDateTime zdt = ZonedDateTime.of( ld , lt , z );
  23.  
  24. Instant instant = zdt.toInstant();
  25.  
  26. ZoneRules rules = z.getRules();
  27.  
  28. ZoneOffset offset = rules.getOffset( instant );
  29.  
  30.  
  31. boolean isDst = rules.isDaylightSavings( instant );
  32. Duration d = null;
  33. if ( isDst )
  34. {
  35. d = rules.getDaylightSavings( instant );
  36. }
  37.  
  38. System.out.println( "zdt = " + zdt );
  39. System.out.println( "instant = " + instant );
  40. System.out.println( "offset = " + offset );
  41. System.out.println( "isDst = " + isDst );
  42. System.out.println( "d = " + d );
  43. }
  44. }
Success #stdin #stdout 0.14s 38736KB
stdin
Standard input is empty
stdout
zdt = 2015-03-31T07:45-03:00[America/Santiago]
instant = 2015-03-31T10:45:00Z
offset = -03:00
isDst = true
d = PT1H