正在显示
1 个修改的文件
包含
24 行增加
和
3 行删除
@@ -10,6 +10,7 @@ import java.time.format.DateTimeFormatter; | @@ -10,6 +10,7 @@ import java.time.format.DateTimeFormatter; | ||
10 | import java.time.format.DateTimeParseException; | 10 | import java.time.format.DateTimeParseException; |
11 | import java.util.Calendar; | 11 | import java.util.Calendar; |
12 | import java.util.Date; | 12 | import java.util.Date; |
13 | +import java.util.Locale; | ||
13 | import java.util.TimeZone; | 14 | import java.util.TimeZone; |
14 | 15 | ||
15 | 16 | ||
@@ -116,6 +117,11 @@ public final class DateUtil { | @@ -116,6 +117,11 @@ public final class DateUtil { | ||
116 | return null; | 117 | return null; |
117 | } | 118 | } |
118 | 119 | ||
120 | + public static void main(String[] args) { | ||
121 | + Date date = formatByyyyyMMddHHmmss("20211031223300"); | ||
122 | + System.out.println(date); | ||
123 | + } | ||
124 | + | ||
119 | //LocalDateTime转换为Date | 125 | //LocalDateTime转换为Date |
120 | public static Date convertLDTToDate(LocalDateTime time) { | 126 | public static Date convertLDTToDate(LocalDateTime time) { |
121 | return Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); | 127 | return Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); |
@@ -570,9 +576,24 @@ public final class DateUtil { | @@ -570,9 +576,24 @@ public final class DateUtil { | ||
570 | return weekDays[w]; | 576 | return weekDays[w]; |
571 | } | 577 | } |
572 | 578 | ||
573 | - public static void main(String[] args) throws ParseException { | ||
574 | - String s = dateToWeek("20200815"); | ||
575 | - System.out.println(s); | 579 | + |
580 | + /** | ||
581 | + * 格式化航班日期类型 | ||
582 | + * @param dateStr | ||
583 | + * @return | ||
584 | + * @throws ParseException | ||
585 | + */ | ||
586 | + public static Date dateFormatFlight(String dateStr) throws ParseException{ | ||
587 | + SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyyyy", Locale.ENGLISH); | ||
588 | + try { | ||
589 | + Date date = sdf.parse(dateStr); | ||
590 | + System.out.println(date); | ||
591 | + return date; | ||
592 | + } catch (ParseException e) { | ||
593 | + // TODO Auto-generated catch block | ||
594 | + e.printStackTrace(); | ||
595 | + } | ||
596 | + return null; | ||
576 | } | 597 | } |
577 | 598 | ||
578 | 599 |
-
请 注册 或 登录 后发表评论