System.out.println(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now(ZoneOffset.UTC)));
DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
// 解析date+time
.appendPattern("yyyyMMddHHmmss")
// 解析毫秒数
.appendValue(ChronoField.MILLI_OF_SECOND, 3).toFormatter();
System.out.println(LocalDateTime.parse("20191112133503997", DATE_TIME_FORMATTER));
Java格式化解析时间
点赞
收藏