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.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. LocalDate date = LocalDate.of ( 2011 , 3 , 13 ) ;
  14. LocalDate nextDate = date.plusDays ( 1 ) ; // The 14th.
  15.  
  16. ZoneId z = ZoneId.of( "America/Edmonton" ) ;
  17. ZonedDateTime start = date.atStartOfDay ( z ) ;
  18. ZonedDateTime end = nextDate.atStartOfDay ( z ) ;
  19.  
  20. Duration d = Duration.between ( start , end ) ;
  21.  
  22. System.out.println ( start ) ;
  23. System.out.println ( end ) ;
  24. System.out.println ( d ) ;
  25. }
  26. }
Success #stdin #stdout 0.12s 57224KB
stdin
Standard input is empty
stdout
2011-03-13T00:00-07:00[America/Edmonton]
2011-03-14T00:00-06:00[America/Edmonton]
PT23H