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 ld = LocalDate.of( 2025 , Month.FEBRUARY , 17 );
  14. ZoneId z = ZoneId.of( "America/Edmonton" );
  15. ZonedDateTime startOfEndDate = ld.atStartOfDay( z );
  16. Instant now = Instant.now( );
  17. Instant then = startOfEndDate.toInstant( );
  18. Duration duration = Duration.between( now , then );
  19. long milliseconds = duration.toMillis( );
  20.  
  21. System.out.println( "range = " + now + "/" + then );
  22. System.out.println( "duration = " + duration );
  23. System.out.println( "milliseconds = " + milliseconds );
  24. }
  25. }
Success #stdin #stdout 0.2s 61396KB
stdin
Standard input is empty
stdout
range = 2024-10-07T20:36:24.665338Z/2025-02-17T07:00:00Z
duration = PT3178H23M35.334662S
milliseconds = 11442215334