fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5.  
  6. class Ideone
  7. {
  8. public static String mostraData(String data) {
  9. String[] array = data.split("/");
  10. if (!(array.length == 3)) return data;
  11. data = "";
  12. for (String each : array)
  13. data += String.format("%02d/", Integer.parseInt(each));
  14. return data.substring(0, data.length() -1);
  15. }
  16.  
  17. public static void main(String[] args) {
  18. System.out.println(mostraData("10/2"));
  19. System.out.println(mostraData("10/2/2015"));
  20. System.out.println(mostraData("5/2/2015"));
  21. System.out.println(mostraData("10/12/15"));
  22. }
  23. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
10/2
10/02/2015
05/02/2015
10/12/15