What's the problem of the isBefore?
package com.codegym.task.task40.task4012;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Period;
import java.time.chrono.ChronoLocalDate;
import java.time.temporal.ChronoUnit;
/*
Useful methods of the DateTime API
*/
public class Solution {
public static void main(String[] args) {
}
public static boolean isLeap(LocalDate date) {
return date.isLeapYear();
}
public static boolean isBefore(LocalDateTime dateTime) {
LocalDate now = LocalDate.now();
LocalDate given = dateTime.toLocalDate();
return !given.isAfter(now);
}
public static LocalTime addTime(LocalTime time, int n, ChronoUnit chronoUnit) {
return time.with(temporal -> temporal.plus(n, chronoUnit));
}
public static Period getPeriodBetween(LocalDate firstDate, LocalDate secondDate) {
if (firstDate.isBefore(secondDate)) {
return Period.between(firstDate, secondDate);
} else {
return Period.between(secondDate, firstDate);
}
}
}