【发布时间】:2017-04-26 05:47:54
【问题描述】:
我有一个时间字符串,格式如下 20170526T043000Z 如何将其转换为毫秒。
【问题讨论】:
-
使用
DateTimeFormatter将值解析为LocalDateTime或ZonedDateTime从那里您可以获得毫秒值。查看Parsing and Formatting了解更多详情
标签: java datetime time calendar jodatime
我有一个时间字符串,格式如下 20170526T043000Z 如何将其转换为毫秒。
【问题讨论】:
DateTimeFormatter 将值解析为LocalDateTime 或ZonedDateTime 从那里您可以获得毫秒值。查看Parsing and Formatting了解更多详情
标签: java datetime time calendar jodatime
你可以在java中使用SimpleDateFormat,因为你知道日期格式。
例如:
String testDate = "20170526T043000Z";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyymmdd'T'HHmmss");
Date parsedDate = simpleDateFormat.parse(testDate);
System.out.println("Time in millis " + parsedDate.getTime());
【讨论】: