|  |  | package com.tianbo.util.Date; | 
|  |  |  | 
|  |  | import javafx.util.converter.LocalDateTimeStringConverter; | 
|  |  |  | 
|  |  | import java.text.ParseException; | 
|  |  | import java.text.SimpleDateFormat; | 
|  |  | import java.time.*; | 
| ... | ... | @@ -23,6 +25,8 @@ public final class DateUtil { | 
|  |  |  | 
|  |  | public static String F14 = "yyyyMMddHHmmss"; | 
|  |  |  | 
|  |  | public static String F17 = "yyyyMMddHHmmssSSS"; | 
|  |  |  | 
|  |  | public static String F10 = "yyyy-MM-dd"; | 
|  |  |  | 
|  |  | public static String F8 = "yyyyMMdd"; | 
| ... | ... | @@ -31,8 +35,9 @@ public final class DateUtil { | 
|  |  |  | 
|  |  | private static Date currentDate = new Date(); | 
|  |  | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | 
|  |  | private static SimpleDateFormat sdf_yyyyMMdd = new SimpleDateFormat("yyyyMMdd"); | 
|  |  | private static SimpleDateFormat timesdf = new SimpleDateFormat("yyyyMMddHHmmss"); | 
|  |  | private static SimpleDateFormat sdf_yyyyMMdd = new SimpleDateFormat(F8); | 
|  |  | private static SimpleDateFormat timesdf = new SimpleDateFormat(F14); | 
|  |  | private static SimpleDateFormat timesdfsss = new SimpleDateFormat(F17); | 
|  |  |  | 
|  |  | public static  String getToday(){ | 
|  |  | return sdf.format(currentDate); | 
| ... | ... | @@ -49,10 +54,40 @@ public final class DateUtil { | 
|  |  | return date; | 
|  |  | } | 
|  |  |  | 
|  |  | /** | 
|  |  | * 用localDatetime转毫秒字符串为时间,JAVA8有BUG,改为用simpleDateFormat转换,这个方法暂时不可用 | 
|  |  | * @param dateStr | 
|  |  | * @return | 
|  |  | */ | 
|  |  | public static Date formatByF17(String dateStr){ | 
|  |  | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(F17); | 
|  |  | LocalDateTime beginDateTime = LocalDateTime.parse(dateStr, formatter); | 
|  |  | Date date = convertLDTToDate(beginDateTime);; | 
|  |  | return date; | 
|  |  | } | 
|  |  |  | 
|  |  | /** | 
|  |  | * 取当前时间 | 
|  |  | * @return  20190916071330 | 
|  |  | */ | 
|  |  | public static String getDDTM(){ | 
|  |  | return timesdf.format(currentDate); | 
|  |  | } | 
|  |  |  | 
|  |  | /** | 
|  |  | * 取当前时间 | 
|  |  | * @return  20190916071330431 | 
|  |  | */ | 
|  |  | public static String getCurrentTime17(){ | 
|  |  | return timesdfsss.format(currentDate); | 
|  |  | } | 
|  |  |  | 
|  |  | /** | 
|  |  | * 日期格式转换返回 | 
|  |  | * @param dateStr | 
|  |  | * @return 20190916071330 | 
|  |  | * @throws DateTimeParseException | 
|  |  | */ | 
|  |  | public static Date formatByyyyyMMddHHmmss(String dateStr) throws DateTimeParseException{ | 
|  |  | //毫秒级的去掉 | 
|  |  | if(dateStr.length()>14){ | 
| ... | ... | @@ -401,4 +436,13 @@ public final class DateUtil { | 
|  |  | return date; | 
|  |  | } | 
|  |  |  | 
|  |  | /**java.time.LocalDateTime --> java.util.Date | 
|  |  | * | 
|  |  | */ | 
|  |  | public void LocalDateTimeToUdate() { | 
|  |  | LocalDateTime localDateTime = LocalDateTime.now(); | 
|  |  | ZoneId zone = ZoneId.systemDefault(); | 
|  |  | Instant instant = localDateTime.atZone(zone).toInstant(); | 
|  |  | java.util.Date date = Date.from(instant); | 
|  |  | } | 
|  |  | } | 
... | ... |  |