Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * ---------------------------------------------------------------------------
- * File name: DateValidator.java
- * Project name: Project 2
- * ---------------------------------------------------------------------------
- * Creator's name and email: Drew Parsons zldp3@goldmail.etsu.edu
- * Course-Section: CSCI1260-201
- * Creation Date: Feb 14, 2011
- * ---------------------------------------------------------------------------
- */
- /**
- * Responsibilities:<br>
- * Enter type responsibilities here<br>
- *
- * <hr>
- * Date created: Feb 14, 2011<br>
- * <hr>
- * @author Drew Parsons
- */
- public class DateValidator
- {
- private static int daysInMonth = 0; //holds the amount of days in the month
- private final static int CURRENT_YEAR = 2011; //this year
- private final static int BOTTOM_YEAR = 1800; //holds an old year for data checking
- public boolean calcDate(int month, int day, int year)
- {
- switch (month)
- {
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12:
- daysInMonth = 31;
- break;
- case 4:
- case 6:
- case 9:
- case 11:
- daysInMonth = 30;
- break;
- case 2:
- if ( ((year % 4 == 0) && !(year % 100 == 0))
- || (year % 400 == 0) )
- daysInMonth = 29;
- else
- daysInMonth = 28;
- break;
- default:
- return false;
- }
- if(day > 0 && day <= daysInMonth && year <= CURRENT_YEAR && year > BOTTOM_YEAR)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /* public String toString()
- {
- return days1 + "/" + month1 + "/" + year1;
- }**/
- }//end DateValidator
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement