|
@@ -336,13 +336,26 @@ public class DateUtil {
|
|
|
|
|
|
|
|
public static boolean judgmentDate(Date date1, Date date2) {
|
|
public static boolean judgmentDate(Date date1, Date date2) {
|
|
|
long cha = date1.getTime() - date2.getTime();
|
|
long cha = date1.getTime() - date2.getTime();
|
|
|
|
|
+ System.out.println(cha);
|
|
|
if (cha < 0) {
|
|
if (cha < 0) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
double result = cha * 1.0 / (1000 * 60 * 60);
|
|
double result = cha * 1.0 / (1000 * 60 * 60);
|
|
|
|
|
+ System.out.println(result);
|
|
|
return result <= 24;
|
|
return result <= 24;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static boolean within24Hours(Date date) {
|
|
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
|
|
+ long mills = l - date.getTime();
|
|
|
|
|
+ int requiredHours = (int) (mills / 1000 / 3600);
|
|
|
|
|
+ return requiredHours <= 24;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
|
+ System.out.println(within24Hours(DateUtil.parse("2022-12-04 08:00:00")));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static long timeDifference(String endDate, String startDate, String tsf) {
|
|
public static long timeDifference(String endDate, String startDate, String tsf) {
|
|
|
try {
|
|
try {
|
|
|
long diff = DateUtil.parse(endDate).getTime() - DateUtil.parse(startDate).getTime();
|
|
long diff = DateUtil.parse(endDate).getTime() - DateUtil.parse(startDate).getTime();
|