ElPatriota / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

Date format sent in client is determined by the data... not the field type. #262

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Send a Product with a ReleaseDate ending in 00:00:00 to the CREATE product 
sample service.

What is the expected output? What do you see instead?

Successful creation is expected.  Instead, the following is received:

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> 
    <code /> 
    <message xml:lang="en-US">Error processing request stream. Error encountered in converting the value from request payload for property 'ReleaseDate' to type 'System.DateTime', which is the property's expected type. See inner exception for more detail.</message> 
    <innererror> 
        <message>The string '2006-11-05T00:00' is not a valid AllXsd value.</message> 
        <type>System.FormatException</type> 
        <stacktrace> at System.Xml.XmlConvert.ToDateTime(String s, XmlDateTimeSerializationMode dateTimeOption)&#xD;
            at System.Data.Services.Parsing.WebConvert.StringToPrimitive(String text, Type targetType)&#xD;
            at System.Data.Services.Serializers.PlainXmlDeserializer.ConvertValuesForXml(Object value, String propertyName, Type typeToBeConverted)</stacktrace> 
    </innererror> 
</error>

What version of the product are you using? On what operating system?

0.7.0 on Linux (Ubuntu 12.04.2 LTS)

Please provide any additional information below.

Looking at the source code, it appears the format is selected depending on the 
data provided:

  public static String formatDateTimeForXml(LocalDateTime localDateTime) {
    if (localDateTime == null)
      return null;

    if (localDateTime.getMillisOfSecond() != 0)
      return localDateTime.toString(DATETIME_WITH_MILLIS_XML);
    else if (localDateTime.getSecondOfMinute() != 0)
      return localDateTime.toString(DATETIME_WITH_SECONDS_XML);
    else
      return localDateTime.toString(DATETIME_XML);
  }

Original issue reported on code.google.com by kbar...@boomi.com on 17 Jun 2013 at 4:20