【问题标题】:Load JSON (from oracle TIMESTAMP) to Dart DateTime将 JSON(从 oracle TIMESTAMP)加载到 Dart DateTime
【发布时间】:2018-07-05 07:57:52
【问题描述】:

这是我从 Oracle 服务器获取 json 的工厂方法。 starttime 是 oracle 中的 TIMESTAMP。

factory Status.fromJson(Map<String, dynamic> status) =>
new Status(

    status['dataSize'],
    status['statusDescription'],
    status['startTime'],          
    status['server']
);

来自 json 的 starttime 不是人类可读的。如何将此纪元时间转换为可读的东西。我试过了

DateTime.parse(status['startTime']

哪个有用。如何使用

DateTime.fromMillisecondsSinceEpoch(startTime)

来自 json。

【问题讨论】:

  • “来自 json 的 starttime 不是人类可读的”是什么意思。值的来源是毫无意义的,相关信息将是值的样子。
  • starttime 的值看起来像 1516920700513 。

标签: json timestamp dart epoch


【解决方案1】:

DartPad example

new DateTime.fromMillisecondsSinceEpoch(1516920700513);

new DateTime.fromMillisecondsSinceEpoch(status['startTime']),   

【讨论】:

    猜你喜欢
    • 2013-07-24
    • 1970-01-01
    • 1970-01-01
    • 2021-11-22
    • 1970-01-01
    • 2021-05-30
    • 2016-10-30
    • 2015-04-20
    • 2020-12-15
    相关资源
    最近更新 更多