diff options
author | Vitaly Takmazov | 2016-01-16 19:13:30 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-01-16 19:13:30 +0300 |
commit | 143513cec90ab176e5c174fb4ed98c249652bda6 (patch) | |
tree | a9649716f8b5ca2aba7fc4d43603467c4ef4cf5a /src/main/java/com/juick/json/MessageSerializer.java | |
parent | 1a39696a6eaf4ea41447e4426ccdcfacec657554 (diff) |
refactoring
Diffstat (limited to 'src/main/java/com/juick/json/MessageSerializer.java')
-rw-r--r-- | src/main/java/com/juick/json/MessageSerializer.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/com/juick/json/MessageSerializer.java b/src/main/java/com/juick/json/MessageSerializer.java index da87d4be..4818722f 100644 --- a/src/main/java/com/juick/json/MessageSerializer.java +++ b/src/main/java/com/juick/json/MessageSerializer.java @@ -40,10 +40,15 @@ public class MessageSerializer extends JSONSerializer<Message> { UserSerializer userSerializer = new UserSerializer(); PlaceSerializer placeSerializer = new PlaceSerializer(); - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + final SimpleDateFormat df; + + public MessageSerializer() { + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + } @Override - public Message deserialize(JSONObject json) throws JSONException { + public Message deserialize(JSONObject json) throws JSONException, ParseException { com.juick.Message jmsg = new com.juick.Message(); jmsg.setMID(json.getInt("mid")); if (json.has("rid")) { @@ -59,12 +64,7 @@ public class MessageSerializer extends JSONSerializer<Message> { jmsg.setText(json.getString("body").replace(""", "\"")); jmsg.setUser(userSerializer.deserialize(json.getJSONObject("user"))); - try { - DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - df.setTimeZone(TimeZone.getTimeZone("UTC")); - jmsg.setDate(df.parse(json.getString("timestamp"))); - } catch (ParseException e) { - } + jmsg.setDate(df.parse(json.getString("timestamp"))); if (json.has("tags")) { JSONArray tags = json.getJSONArray("tags"); |