You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "M Carissimi (JIRA)" <ji...@apache.org> on 2015/05/13 13:24:00 UTC

[jira] [Comment Edited] (OLINGO-657) Milliseconds in DateTime data type

    [ https://issues.apache.org/jira/browse/OLINGO-657?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14541739#comment-14541739 ] 

M Carissimi edited comment on OLINGO-657 at 5/13/15 11:23 AM:
--------------------------------------------------------------

Hi [~mirbo]
we have noticed this issue when we request an entry where one of the key properties is of type DateTime with milliseconds. For example, given the following definition

{code}
<EntityType Name="EXECUTION">
	<Key>
		<PropertyRef Name="NAME"/>
		<PropertyRef Name="START_DATETIME"/>
	</Key>
	<Property Name="NAME" Type="Edm.String" Nullable="false"/>
	<Property Name="START_DATETIME" Type="Edm.DateTime" Nullable="false"/>
	<Property Name="END_DATETIME" Type="Edm.DateTime" Nullable="true"/>
	<Property Name="STATUS" Type="Edm.String" Nullable="false"/>
</EntityType>
{code}

When we request a single entry using {{EXECUTION(NAME='TEST',START_DATETIME=datetime'2015-05-11T12:15:10.14')}}, our code gets the key predicates from the UriInfo instance and then extracts the key predicate literal:
{code}
      List<KeyPredicate> myKeys = aUriInfo.getKeyPredicates();
      for (int i = 0; i < myKeys.size(); i++)
      {
        KeyPredicate myKey = myKeys.get(i);
        String myName = myKey.getProperty().getName();
        String myValue = myKey.getLiteral();
{code}

The property value literal will be {{2015-05-11T12:15:10.14}} and if this is passed to a SimpleDateFormat instance, the incorrect Calendar/Date object will be returned. Using the EdmSimpleType.valueOfString(..) method provides the correct Calendar/Date object.

Cheers
M



was (Author: michele energysys):
Hi [~mirbo]
we have noticed this issue when we request an entry where one of the key properties is of type DateTime with milliseconds. For example, given the following definition

{code}
<EntityType Name="EXECUTION">
	<Key>
		<PropertyRef Name="NAME"/>
		<PropertyRef Name="START_DATETIME"/>
	</Key>
	<Property Name="NAME" Type="Edm.String" Nullable="false"/>
	<Property Name="START_DATETIME" Type="Edm.DateTime" Nullable="false"/>
	<Property Name="END_DATETIME" Type="Edm.DateTime" Nullable="true"/>
	<Property Name="STATUS" Type="Edm.String" Nullable="false"/>
</EntityType>
{code}

When we request a single entry using {{EXECUTION(NAME='TEST',START_DATETIME=datetime'2015-05-11T12:15:10.14')}}, our code gets the key predicates from the UriInfo instance and then extracts the key predicate literal:
{code}
      List<KeyPredicate> myKeys = aUriInfo.getKeyPredicates();
      for (int i = 0; i < myKeys.size(); i++)
      {
        KeyPredicate myKey = myKeys.get(i);
        String myName = myKey.getProperty().getName();
        String myValue = myKey.getLiteral();
{code}

The property value literal will be {{2015-05-11T12:15:10.14)}} and if this is passed to a SimpleDateFormat instance, the incorrect Calendar/Date object will be returned. Using the EdmSimpleType.valueOfString(..) method provides the correct Calendar/Date object.

Cheers
M


> Milliseconds in DateTime data type
> ----------------------------------
>
>                 Key: OLINGO-657
>                 URL: https://issues.apache.org/jira/browse/OLINGO-657
>             Project: Olingo
>          Issue Type: Question
>          Components: odata2-core
>    Affects Versions: V2 2.0.3
>            Reporter: M Carissimi
>            Assignee: Michael Bolz
>
> Hello,
> we need to represent DateTime properties with milliseconds. I understand that OData V2 supports the use of this using the format datetime’yyyy-mm-ddThh:mm[:ss[.fffffff]]’. 
> In our code, a start date time of 11/May/2015 12:15:10.140 (i.e. with milliseconds value of 140) is rendered as 
> {code}
> <d:START_DATETIME m:type="Edm.DateTime">2015-05-11T12:15:10.14</d:START_DATETIME>
> {code}
> When we receive a request for an entry with key parameter START_DATETIME=datetime'2015-05-11T12:15:10.14', this is incorrectly parsed in Java because the format {{yyyy-MM-dd'T'hh:mm:ss.SSS}} returns the value *014* instead of *140* for milliseconds.
> Is there a way to ensure our entries use 3 digits for milliseconds so that we get:
> {code}<d:START_DATETIME m:type="Edm.DateTime">2015-05-11T12:15:10.14</d:START_DATETIME>
> {code}
> Alternatively, does Olingo provide utility classes to convert a datetime() String entry into a Java Date or Calendar?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)