Guest User

Untitled

a guest
Feb 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. static boolean validDate(String x) {
  2. // System.out.println("start checking dates");
  3. boolean valid = false;
  4. int size = 0;
  5. String checkDate = "";
  6. int numCheckDate = 0;
  7. size = x.length();
  8.  
  9. int count = 0;
  10. for (int i = 0; i < size-2; i++) {
  11. //System.out.println(x.charAt(i));
  12. if (x.charAt(i) == '/') {
  13. count++;
  14. }
  15. if (count == 2) {
  16. checkDate += x.charAt(i + 1);
  17. checkDate += x.charAt(i + 2);
  18.  
  19. count = 0;
  20. }
  21.  
  22. if ((checkDate.equals("01")) || (checkDate.equals("02"))||(checkDate.equals("03"))||(checkDate.equals("04"))||(checkDate.equals("05"))||
  23. (checkDate.equals("06"))||(checkDate.equals("07"))||(checkDate.equals("08"))||(checkDate.equals("09"))||(checkDate.equals("10")))
  24. {
  25. valid = true;
  26. } else {
  27. valid = false;
  28. }
  29.  
  30. }
  31.  
  32. // System.out.println(checkDate);
  33. return valid;
  34.  
  35. }
Add Comment
Please, Sign In to add comment