Advertisement
PasteManArs

Untitled

Nov 30th, 2022
804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1.     public static boolean isCorrectDate(int day, int month, int year)
  2.     {
  3.         boolean isLeapYear = ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0));
  4.         if(year > 0)
  5.         {
  6.             if(month >= 1 && month <= 12)
  7.             {
  8.                 if((month == 4 || month == 6 || month == 9 || month == 11) &&  day <= 30)
  9.                     return true;
  10.                 else if((month == 2 && day <= 28) || (month == 2 && day <= 29 && isLeapYear))
  11.                     return true;
  12.                 else if((month == 12 || month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10) &&  day <= 31)
  13.                     return true;
  14.                 else
  15.                     return false;
  16.             }
  17.             else
  18.                 return false;
  19.         }
  20.         else
  21.             return false;
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement