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. import java.util.concurrent.TimeUnit;
  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. String input = "2015/10/25".replace( "/" , "-" );
  15. LocalDate ld = LocalDate.parse( input );
  16.  
  17. long millisOfDay = Long.parseLong( "930" );
  18. long nanosOfDay = TimeUnit.MILLISECONDS.toNanos( millisOfDay ); // Same effect as: ( millisOfDay * 1_000L )
  19. LocalTime lt = LocalTime.ofNanoOfDay( nanosOfDay );
  20.  
  21. ZoneId z = ZoneId.of( "Pacific/Auckland" );
  22. ZonedDateTime zdt = ZonedDateTime.of( ld , lt , z );
  23.  
  24. System.out.println( "ld: " + ld );
  25. System.out.println( "lt: " + lt );
  26. System.out.println( "zdt: " + zdt );
  27.  
  28.  
  29. }
  30. }
Success #stdin #stdout #stderr 0.12s 712192KB
stdin
Standard input is empty
stdout
ld: 2015-10-25
lt: 00:00:00.930
zdt: 2015-10-25T00:00:00.930+13:00[Pacific/Auckland]
stderr
Java HotSpot(TM) Client VM warning: No monotonic clock was available - timed services may be adversely affected if the time-of-day clock changes