DataType从JSON到POJO ZonedDateTime

时间:2017-04-12 17:40:26

标签: java json jackson

我正在使用以下元素解析JSON文件:

{
  "text": "Burn off. Goulburn Mulwaree (974 Currawang Road, Gundary) at 5 Mar 2017 12:44 #NSWRFS #Burnoff #NSWFires",
  "user": {
    "id": "4721717942",
    "name": "NSW Fire Updates"
  },
  "lang": "en",
  "coordinates": {
    "coordinates": [
      149.67931151,
      -34.83702803
    ],
    "type": "Point"
  },
  "created_at": "Sun Mar 05 03:39:31 +0000 2017"
}

我已成功解析此文件中的所有对象。

但对于对象created_at,我想将其变为ZonedTimeDate类型。所以我可以对它们进行操作。目前我只使用String。这是我目前的实施:

public class Tweet {
    private String created_at;

    public Tweet() {
    }

    public String getCreated_at() {
        return created_at;
    }

    public void setCreated_at(String created_at) {
        this.created_at = created_at;
    }

    // Rest of class ...
}

0 个答案:

没有答案