[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [exonerator/release] Set default locale US and default time zone UTC.
commit 53e94d8cd9fc889a62c0cbb39c247e98980323a4
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Sun Apr 12 16:24:31 2020 +0200
Set default locale US and default time zone UTC.
Part of #33655.
---
CHANGELOG.md | 2 ++
.../torproject/metrics/exonerator/ExoneraTorDatabaseImporter.java | 4 ++++
src/main/java/org/torproject/metrics/exonerator/QueryServlet.java | 2 --
src/main/java/org/torproject/metrics/exonerator/ServerMain.java | 5 +++++
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d22bc6f..f6cc649 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,8 @@
* Minor changes
- Improve logging of the database importer.
- Simplify logging configuration.
+ - Set default locale `US` and default time zone `UTC` at the
+ beginning of the execution.
# Changes in version 4.3.0 - 2020-01-15
diff --git a/src/main/java/org/torproject/metrics/exonerator/ExoneraTorDatabaseImporter.java b/src/main/java/org/torproject/metrics/exonerator/ExoneraTorDatabaseImporter.java
index b4d68e5..6a12d15 100644
--- a/src/main/java/org/torproject/metrics/exonerator/ExoneraTorDatabaseImporter.java
+++ b/src/main/java/org/torproject/metrics/exonerator/ExoneraTorDatabaseImporter.java
@@ -39,9 +39,11 @@ import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.HashSet;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
+import java.util.TimeZone;
import java.util.TreeMap;
/* Import Tor descriptors into the ExoneraTor database. */
@@ -52,6 +54,8 @@ public class ExoneraTorDatabaseImporter {
/** Main function controlling the parsing process. */
public static void main(String[] args) {
+ Locale.setDefault(Locale.US);
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
logger.info("Starting ExoneraTor database importer.");
readConfiguration();
openDatabaseConnection();
diff --git a/src/main/java/org/torproject/metrics/exonerator/QueryServlet.java b/src/main/java/org/torproject/metrics/exonerator/QueryServlet.java
index dda63da..2b06ed2 100644
--- a/src/main/java/org/torproject/metrics/exonerator/QueryServlet.java
+++ b/src/main/java/org/torproject/metrics/exonerator/QueryServlet.java
@@ -29,7 +29,6 @@ import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import java.util.TimeZone;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.regex.Pattern;
@@ -224,7 +223,6 @@ public class QueryServlet extends HttpServlet {
String passedTimestampParameter) {
LocalDate timestamp = null;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
dateFormat.setLenient(false);
if (passedTimestampParameter != null
&& passedTimestampParameter.length() > 0) {
diff --git a/src/main/java/org/torproject/metrics/exonerator/ServerMain.java b/src/main/java/org/torproject/metrics/exonerator/ServerMain.java
index 1819a3c..b8ff428 100644
--- a/src/main/java/org/torproject/metrics/exonerator/ServerMain.java
+++ b/src/main/java/org/torproject/metrics/exonerator/ServerMain.java
@@ -9,6 +9,9 @@ import org.eclipse.jetty.xml.XmlConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Locale;
+import java.util.TimeZone;
+
public class ServerMain {
private static final Logger logger
@@ -16,6 +19,8 @@ public class ServerMain {
/** Starts the web server listening for incoming client connections. */
public static void main(String[] args) {
+ Locale.setDefault(Locale.US);
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
try {
Resource jettyXml = Resource.newSystemResource("jetty.xml");
logger.info("Reading configuration from '{}'.", jettyXml);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits