ElPatriota / odata4j

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

Parsing LocalDateTime String from URL encoded String fails #276

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If talking to a SAP LARA system, an a Entity key is datetime, the <id> tag 
cannot be parsed correctly, because the representation of the date 
(ReadingDate=datetime'2014-02-06T00%3A00%3A00') contains the URL encoding 
character ":".
A quick fix is to shadow the org.odata4j.internal.InternalUtil class and 
replace the method parseDateTimeFromXml:

 public static LocalDateTime parseDateTimeFromXml(final String value)
    {

        /*
         * XXX Hack to url encoded data format (ReadingDate=datetime'2014-01-06T00%3A00%3A00).
         */
        String decoded;
        try
        {
            decoded = URLDecoder.decode(value, StandardCharsets.ISO_8859_1.name());
        }
        catch (UnsupportedEncodingException e)
        {
            @SuppressWarnings("deprecation")
            String tmp = URLDecoder.decode(value);
            decoded = tmp;
        }

        Matcher matcher = DATETIME_XML_PATTERN.matcher(decoded);

...

Original issue reported on code.google.com by hannes.a...@gmail.com on 7 Feb 2014 at 7:09

GoogleCodeExporter commented 9 years ago
I attached a sample document.

Original comment by hannes.a...@gmail.com on 7 Feb 2014 at 7:20

Attachments: