1

I am encountering the exception stated below in my android code where I am trying to parse an ODATA service using odata4j JAR library.

java.lang.IllegalArgumentException: Illegal datetime format 2015-05-07T00%3A00%3A00

I am getting the error at line below in Android code:

List list = c.getEntities("EntityName").execute().toList();

My entire stacktrace is stated below:

 Caused by: java.lang.IllegalArgumentException: bad valueString [datetime'2015-05-07T00%3A00%3A00'] as part of keyString [*****='*****',*****='0',***='*****',date=datetime'2015-05-07T00%3A00%3A00',*****='*******']
            at org.odata4j.core.OEntityKey.parse(OEntityKey.java:157)
            at org.odata4j.format.xml.AtomFeedFormatParser.parseEntityKey(AtomFeedFormatParser.java:300)
            at org.odata4j.format.xml.AtomFeedFormatParser.entityFromAtomEntry(AtomFeedFormatParser.java:431)
            at org.odata4j.format.xml.AtomFeedFormatParser.parseEntry(AtomFeedFormatParser.java:349)
            at org.odata4j.format.xml.AtomFeedFormatParser.parseFeed(AtomFeedFormatParser.java:169)
            at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:157)
            at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:45)
            at org.odata4j.consumer.ConsumerQueryEntitiesRequest.doRequest(ConsumerQueryEntitiesRequest.java:67)
            at org.odata4j.consumer.ConsumerQueryEntitiesRequest.getEntries(ConsumerQueryEntitiesRequest.java:50)
            at org.odata4j.consumer.ConsumerQueryEntitiesRequest.execute(ConsumerQueryEntitiesRequest.java:40)
            at *******.MyActivity$LoadSpinners.doInBackground(MyActivity.java:287)
            at *******.MyActivity$LoadSpinners.doInBackground(MyActivity.java:202)
            at android.os.AsyncTask$2.call(AsyncTask.java:287)
            at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:841)
     Caused by: java.lang.IllegalArgumentException: Illegal datetime format 2015-05-07T00%3A00%3A00
            at org.odata4j.internal.InternalUtil.parseDateTimeFromXml(InternalUtil.java:96)
            at org.odata4j.expression.ExpressionParser.readExpression(ExpressionParser.java:462)
            at org.odata4j.expression.ExpressionParser.parse(ExpressionParser.java:64)
            at org.odata4j.core.OEntityKey.parse(OEntityKey.java:152)

There are ****** placed at certain sensitive information like not related properties and app package names.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Dhaval
  • 1,597
  • 11
  • 15
  • The error is quite clear? – Skynet May 11 '15 at 12:24
  • Yes. Totally clear. If you happen to know something regarding it, please do share. I am stuck. – Dhaval May 11 '15 at 12:33
  • `Illegal datetime format 2015-05-07T00%3A00%3A00` – Skynet May 11 '15 at 12:34
  • Exactly. That's the error. – Dhaval May 11 '15 at 12:35
  • The source of your error, You need to get properly formatted date string, now how you do that will solve your error. What is the source of this string? – Skynet May 11 '15 at 12:36
  • ODATA SAP web service. – Dhaval May 11 '15 at 12:37
  • So before processing this string, it would be wise to check if the date format is proper. Now I have struggled my entire life to build something which caters to all date formats - This is just not possible. – Skynet May 11 '15 at 12:37
  • I haven't got a solution yet, but removed the date that was causing the crash for now. That's a temporary fix, but definitely not a solution. I'll post the answer if i come through and get something reliable. – Dhaval May 15 '15 at 13:17

0 Answers0