Joda custom format


(troy) #1

Trying to figure out why my joda custom format is causing an error. I'm trying to match this date string:

Wed May 23 2018 13:45:04 GMT-0700 (Pacific Daylight Time)

with this joda custom format string:

E MMM dd yyyy HH:mm:ss z (zzzz)||epoch_millis

I'm using this in the kibana dev tools console to test it:

PUT /twitter
{}

PUT /twitter/_mapping/_doc
{
    "properties": {
        "TxnDate": {
            "type": "date",
            "format": "E MMM dd yyyy HH:mm:ss z (zzzz)||epoch_millis"
        }
    }
}

Elasticsearch is returning:

{
  "error": {
      "root_cause": [
          {
               "type": "illegal_argument_exception",
               "reason": "Incomplete parser array"
          }
      ],
      "type": "illegal_argument_exception",
      "reason": "Incomplete parser array"
  },
  "status": 400
}

(Christoph) #2

I think the (zzzz) doesn't work. I played around a bit and this comes close to what you want I think:

PUT /twitter
{}

PUT /twitter/_mapping/_doc
{
    "properties": {
        "TxnDate": {
            "type": "date",
            "format": "E MMM dd yyyy HH:mm:ss zZ z||epoch_millis"
        }
    }
}

PUT twitter/_doc/1
{
  "TxnDate" : "Tue Oct 23 1973 00:00:00 GMT+0000 GMT"
}

However I think you are not able to parse this in Joda:

The list of allowed IDs doesn't contain anything about "Pacific Daylight Time", furthermore http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html states:

Zone names: Time zone names ('z') cannot be parsed.

Hope this helps.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.