aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick/json
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/juick/json')
-rw-r--r--src/test/java/com/juick/json/MessageSerializer.java19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/test/java/com/juick/json/MessageSerializer.java b/src/test/java/com/juick/json/MessageSerializer.java
index b49c991a..7ed060dd 100644
--- a/src/test/java/com/juick/json/MessageSerializer.java
+++ b/src/test/java/com/juick/json/MessageSerializer.java
@@ -20,6 +20,7 @@ package com.juick.json;
import com.juick.Message;
import com.juick.Photo;
import com.juick.Tag;
+import com.juick.util.DateFormattersHolder;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -27,26 +28,18 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
import java.util.stream.Collectors;
/**
- *
* @author Ugnich Anton
*/
public class MessageSerializer extends JSONSerializer<Message> {
-
private final static Logger LOGGER = LoggerFactory.getLogger(MessageSerializer.class);
-
+
UserSerializer userSerializer = new UserSerializer();
PlaceSerializer placeSerializer = new PlaceSerializer();
- private final SimpleDateFormat df;
-
public MessageSerializer() {
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- df.setTimeZone(TimeZone.getTimeZone("UTC"));
}
@Override
@@ -66,7 +59,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
jmsg.setText(json.getString("body").replace("&quot;", "\""));
jmsg.setUser(userSerializer.deserialize(json.getJSONObject("user")));
- jmsg.setDate(df.parse(json.getString("timestamp")));
+ jmsg.setDate(DateFormattersHolder.getMessageFormatterInstance().parse(json.getString("timestamp")));
if (json.has("tags")) {
JSONArray tags = json.getJSONArray("tags");
@@ -115,7 +108,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
json.put("body", msg.getText());
}
if (msg.getDate() != null) {
- json.put("timestamp", df.format(msg.getDate()));
+ json.put("timestamp", DateFormattersHolder.getMessageFormatterInstance().format(msg.getDate()));
}
if (msg.getUser() != null) {
json.put("user", userSerializer.serialize(msg.getUser()));
@@ -145,8 +138,4 @@ public class MessageSerializer extends JSONSerializer<Message> {
return json;
}
-
- public SimpleDateFormat getDf() {
- return df;
- }
}