fork(9) 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.temporal.*;
  9. import java.time.format.*;
  10.  
  11.  
  12. /* Name of the class has to be "Main" only if the class is public. */
  13. class Ideone
  14. {
  15. public static void main (String[] args) throws java.lang.Exception
  16. {
  17.  
  18. ZoneId z = ZoneId.of( "America/Montreal" );
  19. ZonedDateTime now = ZonedDateTime.now( z );
  20.  
  21. LocalDate tomorrow = now.toLocalDate().plusDays(1);
  22. ZonedDateTime tomorrowStart = tomorrow.atStartOfDay( z );
  23.  
  24. Duration duration = Duration.between( now , tomorrowStart );
  25. long millisecondsUntilTomorrow = duration.toMillis();
  26.  
  27. System.out.println( "now.toString(): " + now );
  28. System.out.println( "tomorrowStart.toString(): " + tomorrowStart );
  29. System.out.println( "millisecondsUntilTomorrow: " + millisecondsUntilTomorrow );
  30.  
  31. }
  32. }
Success #stdin #stdout 0.16s 4386816KB
stdin
Standard input is empty
stdout
now.toString(): 2017-05-02T12:13:59.379-04:00[America/Montreal]
tomorrowStart.toString(): 2017-05-03T00:00-04:00[America/Montreal]
millisecondsUntilTomorrow: 42360621