Issue #947 fix parsing of DataTime.
Change-Id: Ie49c287850a3e12a748e43aafa0f1a90bce13b04 Former-commit-id: 045952304218c867d8fe89df9828f70632df2d00
This commit is contained in:
parent
c1bacb33b1
commit
b53fe917bc
2 changed files with 13 additions and 4 deletions
|
@ -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 :
|
||||
|
|
|
@ -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"));
|
||||
|
|
Loading…
Add table
Reference in a new issue