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. String input = "2016-01-23 12:34" ;
  14. String inputModified = input.replace( " " , "T" );
  15.  
  16. LocalDateTime ldt = LocalDateTime.parse( inputModified );
  17.  
  18. LocalDateTime ldtLater = ldt.plusMinutes( 10 );
  19.  
  20. System.out.println( "ldt: " + ldt );
  21. System.out.println( "ldtLater: " + ldtLater );
  22.  
  23. ZonedDateTime zdt = LocalDateTime.parse( "2016-01-23 12:34".replace( " " , "T" ) ).atZone( ZoneId.of( "Asia/Karachi" ) ).plusMinutes( 10 ) ;
  24. System.out.println( "zdt: " + zdt );
  25. }
  26. }
Success #stdin #stdout 0.12s 712192KB
stdin
Standard input is empty
stdout
ldt: 2016-01-23T12:34
ldtLater: 2016-01-23T12:44
zdt: 2016-01-23T12:44+05:00[Asia/Karachi]