正在显示
1 个修改的文件
包含
29 行增加
和
0 行删除
| 1 | +package com.example.demo; | ||
| 2 | + | ||
| 3 | +import org.dom4j.DocumentException; | ||
| 4 | +import org.slf4j.Logger; | ||
| 5 | +import org.slf4j.LoggerFactory; | ||
| 6 | + | ||
| 7 | +import java.io.IOException; | ||
| 8 | +import java.time.Instant; | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | +import java.time.ZoneId; | ||
| 11 | +import java.time.format.DateTimeFormatter; | ||
| 12 | +import java.util.Date; | ||
| 13 | + | ||
| 14 | +public class T_TIME_TEST { | ||
| 15 | + protected static final Logger logger = LoggerFactory.getLogger(T_TIME_TEST.class); | ||
| 16 | + | ||
| 17 | + public static void main(String[] args) throws IOException{ | ||
| 18 | + String T_timeStr = "2018-11-14T04:02:00"; | ||
| 19 | + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH:mm:ss"); | ||
| 20 | +// ZonedDateTime depZoneTime = ZonedDateTime.parse(T_timeStr,dateTimeFormatter.ISO_ZONED_DATE_TIME); | ||
| 21 | + LocalDateTime localDateTime = LocalDateTime.parse(T_timeStr,dateTimeFormatter.ISO_DATE_TIME); | ||
| 22 | + ZoneId zone = ZoneId.systemDefault(); | ||
| 23 | + Instant instant = localDateTime.atZone(zone).toInstant(); | ||
| 24 | + Date date = Date.from(instant); | ||
| 25 | + logger.debug(date.toString()); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + | ||
| 29 | +} |
-
请 注册 或 登录 后发表评论