From a35bdcb526d39b566c954add0a909820c0b21412 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Wed, 8 Aug 2012 11:32:57 -0500 Subject: [PATCH] Issue #947 fix parsing of DataTime. Change-Id: Ie49c287850a3e12a748e43aafa0f1a90bce13b04 Former-commit-id: ee8a4896bdab65824c9592d02f0e64c092fdb5ef [formerly cac790ac5af334efafd95bd68fdaa37db518d371] [formerly 97ba96759c3f26ebb9074f4dd692244182a4360a] [formerly 5da238c8b942966f9d757a2a5ccc1f9cbacbaf0b [formerly 97ba96759c3f26ebb9074f4dd692244182a4360a [formerly 30ebbadbbffce0c3b1a236d36be5f3013124e7cd]]] Former-commit-id: 5da238c8b942966f9d757a2a5ccc1f9cbacbaf0b Former-commit-id: 664f9aa2a161dd26a76c59a3bc493a05cfa127d3 [formerly b6cc71bf752b834fa58df544a3de83e3e59889d3] Former-commit-id: 8cdf1f8d1c4a0689c28c9a7057eb4ba3ace3ab1a --- .../pointdata/HoursRefTimePointDataRetrieve.py | 13 +++++++++++-- .../com/raytheon/uf/common/time/util/TimeUtil.java | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cave/com.raytheon.viz.pointdata/localization/pointdata/HoursRefTimePointDataRetrieve.py b/cave/com.raytheon.viz.pointdata/localization/pointdata/HoursRefTimePointDataRetrieve.py index 7d474ad789..ca63efb394 100644 --- a/cave/com.raytheon.viz.pointdata/localization/pointdata/HoursRefTimePointDataRetrieve.py +++ b/cave/com.raytheon.viz.pointdata/localization/pointdata/HoursRefTimePointDataRetrieve.py @@ -41,7 +41,8 @@ class HoursRefTimePointDataRetrieve(RefTimePointDataRetrieve.RefTimePointDataRet super(HoursRefTimePointDataRetrieve, self).__init__(pluginName, site, parameters, keyId, refTime, constraint, maxSize) def _createJarray(self, availableTimes, numHours): - from java.util import Date + from java.util import Date, TimeZone + from java.sql import Timestamp from com.raytheon.uf.common.time import DataTime import jep, time #Get a DataTime numHours from current time @@ -51,7 +52,15 @@ class HoursRefTimePointDataRetrieve(RefTimePointDataRetrieve.RefTimePointDataRet length = len(availableTimes) xdts = [] for i in range(length) : - d = DataTime(availableTimes[length-1-i]) + # Timestamp must be used to parse the time because it correctly handles + # the fractional part of seconds instead of interpreting them as + # milliseconds directly. for example 11.62 is + # interpreted as 11 seconds and 620 milliseconds instead of + # 11 seconds and 62 milliseconds. + milliTime = Timestamp.valueOf(availableTimes[length-1-i]).getTime() + # Timestamp parses into the default timezone so we must offset it to get GMT. + milliTime += TimeZone.getDefault().getOffset(milliTime) + d = DataTime(Date(milliTime)) if d.greaterThan(stDateTime) : xdts.append(d) else : diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java index f137f1813f..481b9a5340 100644 --- a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java @@ -49,10 +49,10 @@ public class TimeUtil { // is expensive the SimpleDateFormat class is not thread-safe, // so calling methods use synchronized private static SimpleDateFormat sdf = new SimpleDateFormat( - "yyyy-MM-dd_HH:mm:ss.S"); + "yyyy-MM-dd_HH:mm:ss.SSS"); private static SimpleDateFormat sqlSdf = new SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss.S"); + "yyyy-MM-dd HH:mm:ss.SSS"); static { sqlSdf.setTimeZone(TimeZone.getTimeZone("GMT"));