From cf4e07b55cb7c81a3cb1f0bb910c7ff59af06bbf 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: 702f11b85d4475f807727a859a431b3662af0b4c [formerly 8d118c392a83f58f7dc98f35285bc0a99b1942f3] [formerly 525c0b21a9f3b7b062f76ce58a02647575939c1e] [formerly b53fe917bc5b7cfbe938d6a58c5c0a112d51c418 [formerly 525c0b21a9f3b7b062f76ce58a02647575939c1e [formerly 045952304218c867d8fe89df9828f70632df2d00]]] Former-commit-id: b53fe917bc5b7cfbe938d6a58c5c0a112d51c418 Former-commit-id: 8ba260212ec345bbb5385de011be3084fda82b42 [formerly 4ed3d04e640908a9e84647f27cced83a601d1e1d] Former-commit-id: 54b3078ad1540d8f7a6b996442c721f570dfe5a6 --- .../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"));