From ba594c6d3192b048737952b248e6ee2b8584ec88 Mon Sep 17 00:00:00 2001 From: Alan Young Date: Thu, 22 Jan 2015 16:19:01 +0100 Subject: Use specific Local.US for date-time strings for protocol use. Default Locale is unsafe as one could, for example, get Arabic numerals instead of ASCII ones. Change-Id: Ib70d271bf433c4928accca3b4802c3ba3cb2aa0e diff --git a/src/com/isode/stroke/base/DateTime.java b/src/com/isode/stroke/base/DateTime.java index 27c85d8..5f22cc3 100644 --- a/src/com/isode/stroke/base/DateTime.java +++ b/src/com/isode/stroke/base/DateTime.java @@ -13,11 +13,12 @@ package com.isode.stroke.base; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Locale; import java.util.TimeZone; public class DateTime { public static Date stringToDate(String date) { - SimpleDateFormat parser = new SimpleDateFormat(format); + SimpleDateFormat parser = new SimpleDateFormat(format, Locale.US); parser.setTimeZone(TimeZone.getTimeZone("UTC")); try { return parser.parse(date); @@ -27,7 +28,7 @@ public class DateTime { } public static String dateToString(Date date) { - SimpleDateFormat parser = new SimpleDateFormat(format); + SimpleDateFormat parser = new SimpleDateFormat(format, Locale.US); parser.setTimeZone(TimeZone.getTimeZone("UTC")); return parser.format(date); } -- cgit v0.10.2-6-g49f6