[teiid-issues] [JBoss JIRA] (TEIID-3938) EdmDate and EdmTimeOfDay output in local timezone

Steven Hawkins (JIRA) issues at jboss.org
Thu Jan 28 14:19:00 EST 2016


    [ https://issues.jboss.org/browse/TEIID-3938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13156110#comment-13156110 ] 

Steven Hawkins commented on TEIID-3938:
---------------------------------------

> No, they are saying the parsing Date or Time should be exactly same in every time zone

Their own code seems to contradict that, as the assume GMT for parsing.  

To highlight the issue:

TimeZone.setDefault(TimeZone.getTimeZone("GMT+1"));
Date date = EdmTimeOfDay.getInstance().valueOfString("11:11:11", true, 4000, 0, 0, true, Date.class);
assertEquals("Thu Jan 01 12:11:11 GMT+01:00 1970", date.toString());
String val = EdmTimeOfDay.getInstance().valueToString(date, true, 4000, 0, 0, true);
assertEquals("11:11:11", val);

The last line will fail because the output will be 12:11:11 instead - which means that the string parse->Java->string cycle is inconsistent when the default timezone is not GMT.

This may just be a misunderstanding of Java Date/Time - see EdmDateTimeOffset.createDateTime the case with value instanceOf Date uses Calendar.getInstance(), but has some comment about UTC - which is not meaningful and should not be different than the java.sql.Time handling.  They should be using Calendar.getInstance("GMT").  The Calendar case has a similar issue.

EdmTimeOfDay and EdmDate only work correctly when represented by either java.sql.Time or Long.  So this shouldn't affect us in the TimeOfDay case as the runtime type will be java.sql.Time.  However it will be an issue with EdmDate that we either have to workaround by converting our runtime values to longs or get them to fix this.


> EdmDate and EdmTimeOfDay output in local timezone
> -------------------------------------------------
>
>                 Key: TEIID-3938
>                 URL: https://issues.jboss.org/browse/TEIID-3938
>             Project: Teiid
>          Issue Type: Bug
>          Components: Misc. Connectors
>            Reporter: Steven Hawkins
>            Assignee: Steven Hawkins
>
> 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.  So when Teiid is on a server not in GMT date and time value sent via the odata4 translator will likely be wrong.
> Ramesh:
> I have posted a question to the Olingo development group here http://markmail.org/search/list:org.apache.olingo.dev#query:list%3Aorg.apache.olingo.dev+page:1+mid:bfghfslrpwyjh6ii+state:results



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the teiid-issues mailing list