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.text.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11.  
  12. public static String formataData(String data) throws Exception {
  13. if (data == null || data.equals(""))
  14. return null;
  15. Date date = null;
  16. DateFormat formatter;
  17. try {
  18. formatter = new SimpleDateFormat("HH:mm:ss");
  19. date = (java.util.Date)formatter.parse(data);
  20. } catch (ParseException e) {
  21. throw e;
  22. }
  23. return formatter.format(date);
  24. }
  25.  
  26. public static void main (String[] args) throws java.lang.Exception
  27. {
  28. String hora = "13:32:00";
  29.  
  30. System.out.println(formataData(hora));
  31. }
  32. }
Success #stdin #stdout 0.15s 321280KB
stdin
Standard input is empty
stdout
13:32:00