[
https://issues.apache.org/jira/browse/OLINGO-864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15132060#comment-15132060
]
Christian Amend commented on OLINGO-864:
----------------------------------------
I am not happy with the System.getProperty code. This feels lika hack to me
because the timezone is not set/retrieved explicitly.
When we developed the code we assumed the incomming value to be in GMT since
this is what the Timestamp object expects in the constructor: time -
milliseconds since January 1, 1970, 00:00:00 GMT. A negative number is the
number of milliseconds before January 1, 1970, 00:00:00 GMT.
The value you get when you call timestamp.toString() then assumes the local
timezone instead of using GMT. This is in my opinion where the issue is
located. Because depending on where you are the timestamp.toString() method
will give different values. This is especially tricky since you can`t ask the
timestamp object which timezone it used during conversion. The actual
millisecond value inside the timestamp object is unchanged however.
So if you call EdmDate.valueOfString and later EdmDate.valueToString you will
get the correct value 2000-01-1.
> EdmDate and EdmTimeOfDay output in local timezone
> -------------------------------------------------
>
> Key: OLINGO-864
> URL: https://issues.apache.org/jira/browse/OLINGO-864
> Project: Olingo
> Issue Type: Bug
> Components: odata4-commons
> Affects Versions: (Java) V4 4.0.0-beta-01
> Reporter: Ramesh Reddy
> Assignee: Ramesh Reddy
> Priority: Critical
> Fix For: (Java) V4 4.2.0
>
>
> EdmDate and EdmTimeOfDay both assume GMT for incoming string values - however
> when the convert from Java objects to string they use the local/default
> Calendar.
> OData TC says parsing Date or Time should be exactly same in every time zone.
> This highlights the issue with EdmDate:
> TimeZone.setDefault(TimeZone.getTimeZone("GMT-1"));
> java.sql.Timestamp date = EdmDate.getInstance().valueOfString("2000-01-01",
> true, 4000, 0, 0, true, java.sql.Timestamp.class);
> assertEquals("1999-12-31 23:00:00.0", date.toString());
> String val = EdmDate.getInstance().valueToString(date, true, 4000, 0, 0,
> true);
> assertEquals("2000-01-01", date.toString());
> The last line fails because the date will be "1999-12-31" instead.
> Linked issue at https://issues.jboss.org/browse/TEIID-3938
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)