I'm getting a jave.text.ParseException error on line 21, I can't seem to get rid of it, can anybody help?!
If I add 'throws Exception' after methods then 'date1' and 'date2' both come back as 31 Dec 2012.
Any help would be greatly appreciated!
package com.codegym.task.task08.task0827;
import java.util.Date;
import java.util.*;
import java.text.*;
import java.time.*;
/*
Working with dates
*/
public class Solution {
public static void main(String[] args) {
System.out.println(isDateOdd("MAY 1 2013"));
}
public static boolean isDateOdd(String date) {
SimpleDateFormat format = new SimpleDateFormat("MMMM D YYYY", Locale.ENGLISH);
Date date1 = format.parse(date);
Date date2 = format.parse("JANUARY 1 2013");
long difference = date1.getTime()-date2.getTime();
long days = difference/86400;
System.out.print(date + " = ");
if (days % 2 != 0)
return true;
else
return false;
}
}