public class Solution {
public static void main(String[] args) {
System.out.println(isDateOdd("JANUARY 2 2020"));
}
public static boolean isDateOdd(String date) {
Date startyear = new Date();
startyear.setHours(0);
startyear.setMinutes(0);
startyear.setSeconds(0);
startyear.setDate(1);
startyear.setMonth(0);
Date newDate = new Date(date);
long distance = newDate.getTime() - startyear.getTime();
int sutki = 24 * 60 * 60 * 1000;
int count = (int) (distance/sutki);
if (count%2!=0) return true;
else return false;
}
}
Не проходит по третьему критерию.package com.javarush.task.task08.task0827;
import java.util.Date;
/*
Работа с датой
*/
public class Solution {
public static void main(String[] args) {
System.out.println(isDateOdd("JANUARY 2 2020"));
}
public static boolean isDateOdd(String date) {
Date startyear = new Date();
startyear.setHours(0);
startyear.setMinutes(0);
startyear.setSeconds(0);
startyear.setDate(1);
startyear.setMonth(0);
Date newDate = new Date(date);
long distance = newDate.getTime() - startyear.getTime();
int sutki = 24 * 60 * 60 * 1000;
int count = (int) (distance/sutki);
if (count%2!=0) return true;
else return false;
}
}