|
@@ -1,5 +1,10 @@
|
|
|
package com.tzld.piaoquan.longarticle.utils;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
|
|
@@ -13,4 +18,14 @@ public class DateUtil {
|
|
|
calendar.set(Calendar.SECOND, 0);
|
|
|
return calendar.getTime();
|
|
|
}
|
|
|
+
|
|
|
+ private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
|
+
|
|
|
+ public static long convertToTimestamp(String timeString) {
|
|
|
+ LocalTime localTime = LocalTime.parse(timeString, formatter);
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.of(today, localTime);
|
|
|
+ return localDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
|
|
+ }
|
|
|
+
|
|
|
}
|