1. Change the string type to LocalDateTime

public static LocalDateTime string2LocalDateTime(String dateStr) {
        return LocalDateTime.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

2. Compare the two dates

If (nowDate.compareTo(endTimeDate) < 0) {// code logic}

3, calculating the date difference time (refer to the address: https://www.cnblogs.com/jpfss.)

java.time.Duration duration = java.time.Duration.between(LocalDateTime startTime, LocalDateTime endTime ); For example: during.tominutes ()// the number of minutes between two time differences toNanos()// nanosecond toMillis()// millisecond toMinutes()// minute toHours()// hour toDays()// days