diff options
author | S129778 <S129778@S129778.campus.tue.nl> | 2014-05-12 10:46:13 +0200 |
---|---|---|
committer | S129778 <S129778@S129778.campus.tue.nl> | 2014-05-12 10:46:13 +0200 |
commit | b1b02d6fee26ca663b3d090798f044188cf8b1c6 (patch) | |
tree | 17920f2a79f433c9ae81f35debe47277cffc65af /src/utils/TwitterDateAdapter.java | |
parent | 519c71b076926af00a97466dd3e859eda030eaef (diff) | |
download | Datafiller-b1b02d6fee26ca663b3d090798f044188cf8b1c6.tar.gz |
Locale adjustment
Diffstat (limited to 'src/utils/TwitterDateAdapter.java')
-rw-r--r-- | src/utils/TwitterDateAdapter.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/utils/TwitterDateAdapter.java b/src/utils/TwitterDateAdapter.java index b3c8f37..0a72750 100644 --- a/src/utils/TwitterDateAdapter.java +++ b/src/utils/TwitterDateAdapter.java @@ -8,6 +8,7 @@ import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import java.lang.reflect.Type; +import java.util.Locale; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; @@ -19,11 +20,12 @@ import org.joda.time.format.DateTimeFormatter; */ public class TwitterDateAdapter implements JsonDeserializer<DateTime>, JsonSerializer<DateTime> { - + private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss Z yyyy") + .withLocale(Locale.ENGLISH) .withOffsetParsed(); - + @Override public DateTime deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) throws JsonParseException { @@ -38,13 +40,13 @@ public class TwitterDateAdapter implements JsonDeserializer<DateTime>, throw new JsonParseException("Invalid date: " + datetime, ex); } } - + @Override public JsonElement serialize(DateTime t, Type type, JsonSerializationContext jsc) { return new JsonPrimitive(formatDateTime(t)); } - + public static String formatDateTime(DateTime t) { return DATE_FORMATTER.print(t); } |