KB Article #177083

Validate Timestamp filter incorrectly interprets a timestamp

Problem

* The Validate Timestamp filter appears to convert time values incorrectly, for example, when using a format like yyyy-MM-dd'T'HH:mm:ss.sss'Z' you see trace output like this:

Time value in expression '${wss.timestamp["Created"]}' is 2015-01-01T18:00:36.377Z
Time in message is Thu Jan 01 13:06:17 CDT 2015


Resolution


-- This is because the format is incorrectly configured in the filter, it should have been yyyy-MM-dd'T'HH:mm:ss.SSS'Z' while in the previous format, it used 'sss', specifying the seconds value twice. Because there were two values for the number of seconds in the time format, Java's SimpleDateFormat uses the later value, adding 377 seconds (6:17) to the hour and replacing the original number of seconds in the time entirely. Similar problems may arise if trying to read in microseconds with the milliseconds format, so a format incorrectly ending in ss.SSSSSS and thus attempting to read a time formatted to the microsecond, would treat the microseconds as milliseconds and format the time to something that was seconds or even minutes later due to the number of "milliseconds" being at least 1000 times larger than it should be.

The 'format of timestamp' field in the filter's configuration uses SimpleDateFormat, so please consult the Java documentation for SimpleDateFormat for further information on writing correct date formats.