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.  
  15. String input = "PT" + "2h 33m 50s".replace( " " , "" ).toUpperCase() ;
  16. Duration d = Duration.parse( input ) ; // PT2H33M50S
  17. String output = d.toString() ;
  18.  
  19. LocalTime lt = LocalTime.NOON.plus( d ) ;
  20.  
  21. System.out.println( "input: " + input );
  22. System.out.println( "output: " + output );
  23. System.out.println( "lt.toString(): " + lt );
  24. }
  25. }
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
input: PT2H33M50S
output: PT2H33M50S
lt.toString(): 14:33:50