有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

json Windows Azure日期格式转换为Java日期

例如,我正在从Azure检索JSON并接收日期为1900-01-01T16:00:00.000Z。现在是JSONObject的这一部分,但是如何正确地将其解析为Java日期格式呢

谢谢你的建议


共 (1) 个答案

  1. # 1 楼答案

    将日期作为Json中的字符串,然后使用SimpleDateFormat对其进行解析:

    SimpleDateFormat sdf=new SimpleDateFormat("/*Look at the API for the format*/");
    Date jsonDate= sdf.parse(/*Date as String from your JSON*/);
    

    要找到正确的格式,您可以查看此问题simpledateformat parsing date with 'Z' literal