fork(6) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Ideone test = new Idedone();
  13. System.out.println(test.formatDate("0"));
  14. System.out.println(test.formatDate("70794"));
  15. System.out.println(test.formatDate("81573"));
  16. System.out.println(test.formatDate("22217"));
  17. }
  18.  
  19. public String formatDate(String date){
  20. String birthDate = null;
  21. switch (date.length()) {
  22. case 5:
  23. if(date.charAt(3) == '0' || date.charAt(3) == '1'){
  24. birthDate = "20" + date.substring(3) + "-0" + date.charAt(0) + "-" + date.substring(1,3);
  25. }
  26. else{
  27. birthDate = "19" + date.substring(3) + "-0" + date.charAt(0) + "-" + date.substring(1,3);
  28. }
  29. break;
  30. case 6:
  31. if(date.charAt(4) == '0' || date.charAt(4) == '1'){
  32. birthDate = "20" + date.substring(4) + "-" + date.substring(0,2) + "-" + date.substring(2,4);
  33. }
  34. else{
  35. birthDate = "19" + date.substring(4) + "-" + date.substring(0,2) + "-" + date.substring(2,4);
  36. }
  37. break;
  38. default:
  39. birthDate = null;
  40. break;
  41. }
  42. return birthDate;
  43. }
  44. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:12: error: cannot find symbol
		Ideone test = new Idedone();
		                  ^
  symbol:   class Idedone
  location: class Ideone
1 error
stdout
Standard output is empty