Below is a framework of a function is Valid Day that checks if a given date of a
ID: 3675346 • Letter: B
Question
Below is a framework of a function is Valid Day that checks if a given date of a year is valid. Complete the body of this function so that it will produce a correct answer for any input date. As we know, there are 29 days in the February of a leap year (such as this year, 2016). In order to verify a date, we need to know if a given year is a leap year. A leap year is any year divisible by 4, except that a year divisible tV 100 is not a leap year, except that a year divisible by 400 is a leap year after all. Hence, 1800 and 1900 are not leap years, but 1600 and 2000 are.Explanation / Answer
Here is the method where you can understand method logic for calculating Data
public boolean is ValidDay(String dateToValidate, String dateFromat){
if(dateToValidDay == null){
return false;
}
SimpleDateFormat sdf = new SimpleDateFormat(dateFromat);
sdf.setLenient(false);
try {
Date date = sdf.parse(dateToValidate);
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
return false;
} return true;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.