3 Replies Latest reply: Jul 8, 2011 12:47 PM by 864501 RSS

    Error “Illegal datetime format” when tying to parse Facebook Insights

    864501
      Trying to use OData4j to get Facebook Insights data for my page using the following code:

      ODataConsumer consumer;
      oentitykey = OEntityKey.parse("blahblah");
      String URI = "http://facebook-insights.cloudapp.net/Insights/blah-
      blahbl";
      consumer = ODataConsumer.create(URI);
      for (OEntity app : consumer.getEntities("PageMetrics")) {
      System.out.println(app);
      }

      I get the following exception: Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: bad keyString: datetime'2011-05-31T00%3A00%3A00' Caused by: java.lang.IllegalArgumentException: Illegal datetime format 2011-05-31T00%3A00%3A00

      this is the line in the raw data that I think it is trying to parse: "end_time": "2011-05-31T07:00:00+0000"

      When I use PowerPivot for Excel to display the data, it displays it fine.
        • 1. Re: Error “Illegal datetime format” when tying to parse Facebook Insights
          jschellSomeoneStoleMyAlias
          Post the entire stack trace.

          However if the error originates in the library then the library is the source of the problem. Which mean you fix it there, someone else fixes it or you find some other code to use.
          • 2. Re: Error “Illegal datetime format” when tying to parse Facebook Insights
            864501
            I found out that w/ 90% probability, the cause is the facebook insights, but their forum fails to respond to any questions. The problem is the date-time format contains the string "%3A" instead of a ":". so now i am trying to figure out how to get odata4j to intercept the response from the service and modify it first before trying to parse it, but i dont think anyone here can help me unless they know how odata4j works.

            Here is the stack anyway:
            Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: bad keyString: datetime'2011-06-07T00%3A00%3A00'
                 at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:49)
                 at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:487)
                 at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:487)
                 at com.company.facebook.Main.main(Main.java:52)
            Caused by: java.lang.IllegalArgumentException: bad keyString: datetime'2011-06-07T00%3A00%3A00'
                 at org.odata4j.core.OEntityKey.parse(OEntityKey.java:144)
                 at org.odata4j.format.xml.AtomFeedFormatParser.parseAtomEntryId(AtomFeedFormatParser.java:405)
                 at org.odata4j.format.xml.AtomFeedFormatParser.entityFromAtomEntry(AtomFeedFormatParser.java:385)
                 at org.odata4j.format.xml.AtomFeedFormatParser.parseEntry(AtomFeedFormatParser.java:303)
                 at org.odata4j.format.xml.AtomFeedFormatParser.parseFeed(AtomFeedFormatParser.java:159)
                 at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:147)
                 at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:36)
                 at org.odata4j.consumer.OQueryRequestImpl$EntryIterator.advance(OQueryRequestImpl.java:192)
                 at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:47)
                 ... 3 more
            Caused by: java.lang.IllegalArgumentException: Illegal datetime format 2011-06-07T00%3A00%3A00
                 at org.odata4j.internal.InternalUtil.parseDateTime(InternalUtil.java:109)
                 at org.odata4j.expression.ExpressionParser.readExpression(ExpressionParser.java:400)
                 at org.odata4j.expression.ExpressionParser.parse(ExpressionParser.java:56)
                 at org.odata4j.core.OEntityKey.parse(OEntityKey.java:139)
                 ... 11 more
            • 3. Re: Error “Illegal datetime format” when tying to parse Facebook Insights
              DrClap
              861498 wrote:
              The problem is the date-time format contains the string "%3A" instead of a ":".
              Which means it has been URL-encoded. If you can get your hands (or code) on the format then URL-decoding it should take care of that problem. Or perhaps it's just bad input from wherever that data is being taken.