【问题标题】:Time conversion in java of format 20170526T043000Z [duplicate]格式为20170526T043000Z的java中的时间转换[重复]
【发布时间】:2017-04-26 05:47:54
【问题描述】:

我有一个时间字符串,格式如下 20170526T043000Z 如何将其转换为毫秒。

【问题讨论】:

  • 使用DateTimeFormatter 将值解析为LocalDateTime 或ZonedDateTime 从那里您可以获得毫秒值。查看Parsing and Formatting了解更多详情

标签: java datetime time calendar jodatime


【解决方案1】:

你可以在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());

【讨论】:

    猜你喜欢
    • 2019-07-04
    • 2014-01-12
    • 2020-11-24
    • 2023-03-22
    • 2014-01-29
    • 2012-09-17
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多