fork 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. // Setting to January 29th, 1920 at 00:00:00 in UTC.
  15. LocalDate ld = LocalDate.of( 1920 , Month.JANUARY , 29 ) ;
  16. LocalTime lt = LocalTime.MIN ;
  17. ZoneOffset offset = ZoneOffset.UTC ;
  18. OffsetDateTime odt = OffsetDateTime.of( ld , lt , offset ) ;
  19. System.out.println( "odt.toString(): " + odt ) ;
  20.  
  21. // Add 3 hours at a time, 25 times.
  22. Duration d = Duration.ofHours( 3 ) ;
  23. for( int i = 0 ; i < 25 ; i ++ )
  24. {
  25. System.out.println( odt ) ;
  26. // Set up the next loop.
  27. odt = odt.plus( d ) ;
  28. }
  29. }
  30. }
Success #stdin #stdout 0.09s 36804KB
stdin
Standard input is empty
stdout
odt.toString(): 1920-01-29T00:00Z
1920-01-29T00:00Z
1920-01-29T03:00Z
1920-01-29T06:00Z
1920-01-29T09:00Z
1920-01-29T12:00Z
1920-01-29T15:00Z
1920-01-29T18:00Z
1920-01-29T21:00Z
1920-01-30T00:00Z
1920-01-30T03:00Z
1920-01-30T06:00Z
1920-01-30T09:00Z
1920-01-30T12:00Z
1920-01-30T15:00Z
1920-01-30T18:00Z
1920-01-30T21:00Z
1920-01-31T00:00Z
1920-01-31T03:00Z
1920-01-31T06:00Z
1920-01-31T09:00Z
1920-01-31T12:00Z
1920-01-31T15:00Z
1920-01-31T18:00Z
1920-01-31T21:00Z
1920-02-01T00:00Z