diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-05-12 11:02:01 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-05-12 11:02:01 +0200 |
commit | 98206c3aede24f7820c330f7e54e7247acc38c67 (patch) | |
tree | ea916a0ad20afd9e888e1cf438787784a761b806 | |
parent | 771420398f74911f8bbf864f138704a0e99c863a (diff) | |
parent | b1b02d6fee26ca663b3d090798f044188cf8b1c6 (diff) | |
download | Datafiller-98206c3aede24f7820c330f7e54e7247acc38c67.tar.gz |
Merge branch 'master' of git.lekensteyn.nl:tue/2IOC0-DBL/Datafiller
-rw-r--r-- | src/database/QueryUtils.java | 3 | ||||
-rw-r--r-- | src/utils/TwitterDateAdapter.java | 10 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/database/QueryUtils.java b/src/database/QueryUtils.java index b103a06..a37b806 100644 --- a/src/database/QueryUtils.java +++ b/src/database/QueryUtils.java @@ -3,6 +3,7 @@ package database; import data.Tweet; import data.User; import java.sql.SQLException; +import java.util.Locale; /** * Utilities to create queries. @@ -101,7 +102,7 @@ public class QueryUtils { tweetStatement.setString("text", tweetText); if (tweet.coordinates != null) { float[] coords = tweet.coordinates.coordinates; - String coords_str = String.format("%f,%f", coords[0], coords[1]); + String coords_str = String.format(Locale.ENGLISH, "%f,%f", coords[0], coords[1]); tweetStatement.setString("coordinates", coords_str); } else { tweetStatement.setString("coordinates", null); 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); } |