Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean isCorrectDate(int day, int month, int year)
- {
- boolean isLeapYear = ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0));
- if(year > 0)
- {
- if(month >= 1 && month <= 12)
- {
- if((month == 4 || month == 6 || month == 9 || month == 11) && day <= 30)
- return true;
- else if((month == 2 && day <= 28) || (month == 2 && day <= 29 && isLeapYear))
- return true;
- else if((month == 12 || month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10) && day <= 31)
- return true;
- else
- return false;
- }
- else
- return false;
- }
- else
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement