com/codegym/task/task08/task0827/Solution.java:24: error: unreported exception java.text.ParseException; must be caught or declared to be thrown
Date dd = new SimpleDateFormat("MMMM d yyyy").parse(s);
Why is that not compiling...million thanks in advance!
package com.codegym.task.task08.task0827;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.*;
/*
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) {
//Converting the date format from "MAY 1 2013" to "May 1 2013", tested, np at all.
char[] list = date.toCharArray();
for (int i=1; list[i] != ' '; i++) list[i] = Character.toLowerCase(list[i]);
String s = new String(list);
//The only problem lays here: parsing the string into date,
// which I totally don't understand why it's not working, crying for help!
Date dd = new SimpleDateFormat("MMMM d yyyy").parse(s);
//Making the odd-day to true and even-day to false, tested, np at all
dd.setYear(70);
int value = (int) (dd.getTime() / (1000*3600*24));
return (value%2 == 0);
}
}