From ae94463cce9b26ca26d7075d386b0724a2cb34a8 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 14 Feb 2018 20:10:49 +0100 Subject: add timezone info to fix UTC problem --- src/main/java/at/gv/util/MiscUtil.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/at/gv/util/MiscUtil.java b/src/main/java/at/gv/util/MiscUtil.java index 97da3dc..7ad055e 100644 --- a/src/main/java/at/gv/util/MiscUtil.java +++ b/src/main/java/at/gv/util/MiscUtil.java @@ -32,6 +32,7 @@ import java.util.Formatter; import java.util.GregorianCalendar; import java.util.Iterator; import java.util.Properties; +import java.util.TimeZone; import javax.servlet.http.HttpServletRequest; import javax.xml.datatype.DatatypeConfigurationException; @@ -354,13 +355,17 @@ public class MiscUtil { } public static Date parseDate(String dateString) { - return parseDate(dateString, "dd.MM.yyyy"); + return parseDate(dateString, "dd.MM.yyyy", TimeZone.getTimeZone("UTC")); } - public static Date parseDate(String dateString, String pattern) { + public static Date parseDate(String dateString, String pattern, TimeZone zone) { MiscUtil.assertNotNull(dateString, "dateString"); MiscUtil.assertNotNull(pattern, "pattern"); SimpleDateFormat sdf = new SimpleDateFormat(pattern); + + if (zone != null) + sdf.setTimeZone(zone); + try { return sdf.parse(dateString); } catch (ParseException e) { -- cgit v1.2.3