[QFJ-104] Time Zone Problem Created: 13/Nov/06  Updated: 11/May/07  Resolved: 11/May/07

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.0.4
Fix Version/s: None

Type: Improvement Priority: Default
Reporter: Welf Wustlich Assignee: Steve Bate
Resolution: Not a bug Votes: 0
Labels: None
Environment:

java netbeans



 Description   

We are getting market data snapshots from Forex Hotspot
Within these messages the timestamp is in UTC but quickfix was comming up with local time, because it uses a conversion class UTC-timestamp-converter.
In the result I had some reference problems i.e. problems to find certain data from my database in the message log.
Question: is it possible, to get the timestamp just as the original timestamp from the FIX-message ?

Thanks, Welf



 Comments   
Comment by Steve Bate [ 14/Nov/06 ]

QFJ will parse the timestamp string as a UTC date. At that point it's a java.util.Date object. If you format it back to a string (for a database query, for example) you must use a formatter that is configured for the UTC timezone. Otherwise, the java.util.DateFormatter will format the java.util.Date for the default (usually local) time zone. Could this explain the behavior you are seeing? If not, can you submit a simple unit test showing the problem you are seeing? Thanks.

Comment by Welf Wustlich [ 14/Nov/06 ]

Our solution now is to convert the local timestamp back to UTC, but this solution is slower and less stable than if we could simply switch of the conversion.
You wrote, that the conversion is done finally using a java.util.date object, thats correct but before you have the following stack trace in QFJ from FieldMap.java:
public UtcTimeStampField getField(UtcTimeStampField field) throws FieldNotFound

calls in UtcTimestampConverter (also in QFJ):
public static Date convert(String value) throws FieldConvertError

This last function makes all the conversions to local time ;-(.

We are calling:
SendingTime st = new SendingTime();
message.getHeader().getField(st);

What was confusing us:
public UtcTimeStampField getField(UtcTimeStampField field)
returns local time and not how the return value suggests a UtcTimeStamp.
What is also confusing us:
We expected to get the sending time which is written in the message logs.

Question: Why this conversion and how to avoid without a complicated conversion back to UTC.

Best regards, Welf

Comment by Steve Bate [ 10/May/07 ]

I'm sorry, but I don't understand the issue here. The UtcTimestampConverter uses the UTC time zone when parsing a timestamp string, not the local time. Are you sure you aren't printing the Date returned from the conversion using either Date.toString() or a DateFormatter that hasn't been configured for UTC? If you are using a DateFormatter (e.g., SimpleDateFormatter) you must set the correct timezone (UTC) on the formatter before printing the date. Otherwise, the formatter will print the date in the default timezone of the JVM (usually the local time zone).

Comment by Steve Bate [ 11/May/07 ]

QFJ only uses UTC. If you are using java.util.Date objects returned from the UTC converter and printing them or converting them to strings or using them in database queries you must be sure to associate the UTC time zone when performing those operations. That's outside the scope of QFJ.

Generated at Sat Nov 23 11:21:25 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.