Hello there,
I tried this solution, but it fails at parsing the first date format and I can't figure out why.
Any ideas would be appreciated.
Thanks
package de.codegym.task.task08.task0827;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
/*
Mit Datumsangaben arbeiten
*/
public class Solution {
public static void main(String[] args) {
System.out.println(istUngeradesDatum("MAY 1 2013"));
System.out.println(istUngeradesDatum("JANUARY 2 2020"));
System.out.println(istUngeradesDatum("JANUARY 3 1990"));
}
public static boolean istUngeradesDatum(String date) {
DateTimeFormatter f = DateTimeFormatter.ofPattern("MMMM d yyyy", Locale.ENGLISH);
LocalDate input = LocalDate.parse(date, f);
return input.getDayOfYear() % 2 != 0;
}
}