|
|
@@ -8,6 +8,8 @@ import java.math.RoundingMode;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.format.DateTimeFormatterBuilder;
|
|
|
+import java.time.temporal.ChronoField;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
@@ -339,12 +341,18 @@ public class DateUtils {
|
|
|
}
|
|
|
|
|
|
public static boolean checkIfFullDayDifference(String timeStr) {
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ DateTimeFormatter formatter = new DateTimeFormatterBuilder()
|
|
|
+ .appendPattern("yyyy-MM-dd HH:mm:ss")
|
|
|
+ .optionalStart()
|
|
|
+ .appendLiteral('.')
|
|
|
+ .appendFraction(ChronoField.MILLI_OF_SECOND, 1, 3, false)
|
|
|
+ .optionalEnd()
|
|
|
+ .toFormatter();
|
|
|
LocalDateTime givenTime = LocalDateTime.parse(timeStr, formatter);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
- long hoursDifference = ChronoUnit.MINUTES.between(givenTime, now);
|
|
|
- return Math.abs(hoursDifference) >= 5;
|
|
|
+ long minutesDifference = ChronoUnit.MINUTES.between(givenTime, now);
|
|
|
+ return Math.abs(minutesDifference) >= 5;
|
|
|
}
|
|
|
|
|
|
public static LocalDateTime contactTime(LocalDateTime targetTime ) {
|