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.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. System.out.println(
  15. Instant.now().atZone( ZoneId.of( "Europe/Paris" ) ).toLocalDate().atStartOfDay( ZoneId.of( "Europe/Paris" ) ).getClass().getCanonicalName()
  16. );
  17.  
  18. Instant instant = Instant.now() ;
  19. ZoneId z = ZoneId.of( "Europe/Paris" ) ;
  20. ZonedDateTime zdt = instant.atZone( z ) ;
  21. LocalDate ld = zdt.toLocalDate() ;
  22. LocalDate ldNextDay = ld.plusDays( 1 ) ;
  23. ZonedDateTime zdtStartOfNextDay = ldNextDay.atStartOfDay( z ) ;
  24.  
  25. System.out.println( instant ) ; // 2020-04-13T00:15:25.235341Z
  26. System.out.println( zdt ) ; // 2020-04-13T02:15:25.235341+02:00[Europe/Paris]
  27. System.out.println( ld ) ; // 2020-04-13
  28. System.out.println( ldNextDay ) ; // 2020-04-14
  29. System.out.println( zdtStartOfNextDay ) ; // 2020-04-14T00:00+02:00[Europe/Paris]
  30. }
  31. }
Success #stdin #stdout 0.11s 36060KB
stdin
Standard input is empty
stdout
java.time.ZonedDateTime
2020-04-13T00:16:29.838095Z
2020-04-13T02:16:29.838095+02:00[Europe/Paris]
2020-04-13
2020-04-14
2020-04-14T00:00+02:00[Europe/Paris]