# Joda problem!

**URL:** https://discuss.elastic.co/t/joda-problem/20330
**Category:** Elasticsearch
**Created:** [October 20, 2014, 7:06am UTC](https://discuss.elastic.co/t/joda-problem/20330 "2014-10-20T07:06:44Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![kodo65](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodo65/32/1185_2.png) [@kodo65](https://discuss.elastic.co/u/kodo65)
#### Post date: [October 20, 2014, 7:06am UTC](https://discuss.elastic.co/t/joda-problem/20330/1 "2014-10-20T07:06:44Z")

</div>

Hi!

I've been struggling with two date formats. I'll give you a sample and the  
corresponding date format I've used:

1. "Oct 20, 2014 8:42:41 AM" : MMM d YYYY hh:mm:ss aa
2. "Mon Oct 20 06:42:41 +0000 2014" : EEE MMM d HH:mm:ss Z YYYY

I've used the following mapping:

{  
"settings" : {  
"index" : {  
"number\_of\_shards" : 1,  
"number\_of\_replicas" : 1  
}  
},  
"mappings" : {  
"envelope\_v1" : {  
"\_all" : { "enabled" : true },  
"\_id" : { "index" : "not\_analyzed", "store" : false, "path" :  
"id" },  
"\_timestamp" : { "enabled" : true, "path" : "createdAt" },  
"\_ttl" : { "enabled" : true, "default" : "30d" },  
"properties" : {  
"id" : { "type" : "string", "store" : false, "index" : "no"  
},  
"createdAt" : { "type" : "date", "format" : "MMM d YYYY  
hh:mm:ss aa", "store" : false, "index" : "no" },  
"ref" : { "type" : "string", "store" : false, "index" :  
"no" },  
"sourceType" : { "type" : "string", "store" : false,  
"index" : "no" },  
"search" : { "type" : "string", "store" : false, "index" :  
"no" },  
"source.created\_at" : { "type" : "date", "format" : "EEE  
MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
"source.timestamp\_ms" : { "type" : "date", "store" : false,  
"index" : "no" },  
"source.user.created\_at" : { "type" : "date", "format" :  
"EEE MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
"source.analysis.nlp" : { "type" : "object", "store" :  
false, "index" : "no" }  
}  
}  
}  
}

While adding data I get the following exception:

java.lang.IllegalArgumentException: Invalid format: "Mon Oct 20 06:30:52  
+0000 2014"  
at  
org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:754)

What am I doing wrong here?

Cheers

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/87eb26ef-6a72-4049-a62a-cfa504acd2ca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/87eb26ef-6a72-4049-a62a-cfa504acd2ca%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [October 20, 2014, 7:32am UTC](https://discuss.elastic.co/t/joda-problem/20330/2 "2014-10-20T07:32:42Z")

</div>

You have a comma in "Oct 20, 2014 8:42:41 AM"

"Oct 20 2014 8:42:41 AM" will work.

Jörg

On Mon, Oct 20, 2014 at 9:06 AM, Peter Litsegård \<[peter.litsegaard@gmail.com](mailto:peter.litsegaard@gmail.com)

> wrote:

> Hi!
> 
> I've been struggling with two date formats. I'll give you a sample and the  
> corresponding date format I've used:
> 
> 1. "Oct 20, 2014 8:42:41 AM" : MMM d YYYY hh:mm:ss aa
> 2. "Mon Oct 20 06:42:41 +0000 2014" : EEE MMM d HH:mm:ss Z YYYY
> 
> I've used the following mapping:
> 
> {  
> "settings" : {  
> "index" : {  
> "number\_of\_shards" : 1,  
> "number\_of\_replicas" : 1  
> }  
> },  
> "mappings" : {  
> "envelope\_v1" : {  
> "\_all" : { "enabled" : true },  
> "\_id" : { "index" : "not\_analyzed", "store" : false, "path" :  
> "id" },  
> "\_timestamp" : { "enabled" : true, "path" : "createdAt" },  
> "\_ttl" : { "enabled" : true, "default" : "30d" },  
> "properties" : {  
> "id" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "createdAt" : { "type" : "date", "format" : "MMM d YYYY  
> hh:mm:ss aa", "store" : false, "index" : "no" },  
> "ref" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "sourceType" : { "type" : "string", "store" : false,  
> "index" : "no" },  
> "search" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "source.created\_at" : { "type" : "date", "format" : "EEE  
> MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.timestamp\_ms" : { "type" : "date", "store" :  
> false, "index" : "no" },  
> "source.user.created\_at" : { "type" : "date", "format" :  
> "EEE MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.analysis.nlp" : { "type" : "object", "store" :  
> false, "index" : "no" }  
> }  
> }  
> }  
> }
> 
> While adding data I get the following exception:
> 
> java.lang.IllegalArgumentException: Invalid format: "Mon Oct 20 06:30:52  
> +0000 2014"  
> at  
> org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:754)
> 
> What am I doing wrong here?
> 
> Cheers
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/87eb26ef-6a72-4049-a62a-cfa504acd2ca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/87eb26ef-6a72-4049-a62a-cfa504acd2ca%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/87eb26ef-6a72-4049-a62a-cfa504acd2ca%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/87eb26ef-6a72-4049-a62a-cfa504acd2ca%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFe8BPBRN%2BVgC\_x-8r-vGk%3Djvz9aBhcSSyr66Qk7QHT7w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFe8BPBRN%2BVgC_x-8r-vGk%3Djvz9aBhcSSyr66Qk7QHT7w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![kodo65](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodo65/32/1185_2.png) [@kodo65](https://discuss.elastic.co/u/kodo65)
#### Post date: [October 20, 2014, 7:43am UTC](https://discuss.elastic.co/t/joda-problem/20330/3 "2014-10-20T07:43:41Z")

</div>

Hi Jörg!

Thanks for your response. However, IMHO I don't think this is the problem.  
I changed the Joda specifikation in (1) to "MMM d',' YYYY hh:mm:ss aa" and  
when I used this simple test code

```
             DateTime dt = new DateTime();
             DateTimeFormatter fmt = DateTimeFormat.forPattern("MMM 

```

d',' YYYY KK:mm:ss aa");  
System.out.println(json);  
String str = fmt.print(dt);

I got the following printout:

Oct 20, 2014 09:35:42 AM

which corresponds nicely to the data I try to index: ...4","createdAt":"Oct  
20, 2014 9:35:40 AM"... (just an extract from the complete JSON document)

I changed the mapping for "createdAt" to "MMM d',' YYYY hh:mm:ss aa" BUT I  
still get exactly the same error...

VERY frustrating...

Cheers

On Monday, October 20, 2014 9:06:44 AM UTC+2, Peter Litsegård wrote:

> Hi!
> 
> I've been struggling with two date formats. I'll give you a sample and the  
> corresponding date format I've used:
> 
> 1. "Oct 20, 2014 8:42:41 AM" : MMM d YYYY hh:mm:ss aa
> 2. "Mon Oct 20 06:42:41 +0000 2014" : EEE MMM d HH:mm:ss Z YYYY
> 
> I've used the following mapping:
> 
> {  
> "settings" : {  
> "index" : {  
> "number\_of\_shards" : 1,  
> "number\_of\_replicas" : 1  
> }  
> },  
> "mappings" : {  
> "envelope\_v1" : {  
> "\_all" : { "enabled" : true },  
> "\_id" : { "index" : "not\_analyzed", "store" : false, "path" :  
> "id" },  
> "\_timestamp" : { "enabled" : true, "path" : "createdAt" },  
> "\_ttl" : { "enabled" : true, "default" : "30d" },  
> "properties" : {  
> "id" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "createdAt" : { "type" : "date", "format" : "MMM d YYYY  
> hh:mm:ss aa", "store" : false, "index" : "no" },  
> "ref" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "sourceType" : { "type" : "string", "store" : false,  
> "index" : "no" },  
> "search" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "source.created\_at" : { "type" : "date", "format" : "EEE  
> MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.timestamp\_ms" : { "type" : "date", "store" :  
> false, "index" : "no" },  
> "source.user.created\_at" : { "type" : "date", "format" :  
> "EEE MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.analysis.nlp" : { "type" : "object", "store" :  
> false, "index" : "no" }  
> }  
> }  
> }  
> }
> 
> While adding data I get the following exception:
> 
> java.lang.IllegalArgumentException: Invalid format: "Mon Oct 20 06:30:52  
> +0000 2014"  
> at  
> org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:754)
> 
> What am I doing wrong here?
> 
> Cheers

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/71744ebf-91ad-4fbe-bc5e-b7aa3f457881%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/71744ebf-91ad-4fbe-bc5e-b7aa3f457881%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [October 20, 2014, 7:53am UTC](https://discuss.elastic.co/t/joda-problem/20330/4 "2014-10-20T07:53:57Z")

</div>

Maybe the old mapping is still active?

This works here:

import org.elasticsearch.common.joda.FormatDateTimeFormatter;  
import org.elasticsearch.common.joda.Joda;  
import org.elasticsearch.common.joda.time.DateTime;  
import org.testng.annotations.Test;

public class JodaTest {

```
@Test
public void joda() {
    FormatDateTimeFormatter f = Joda.forPattern("MMM d',' YYYY KK:mm:ss

```

aa");  
DateTime t = f.parser().parseDateTime("Oct 20, 2014 09:35:42 AM");  
System.err.println(f.printer().print(t));  
}  
}

Jörg

On Mon, Oct 20, 2014 at 9:43 AM, Peter Litsegård \<[peter.litsegaard@gmail.com](mailto:peter.litsegaard@gmail.com)

> wrote:

> Hi Jörg!
> 
> Thanks for your response. However, IMHO I don't think this is the problem.  
> I changed the Joda specifikation in (1) to "MMM d',' YYYY hh:mm:ss aa" and  
> when I used this simple test code
> 
> ```
> DateTime dt = new DateTime();
> DateTimeFormatter fmt = DateTimeFormat.forPattern("MMM
> 
> ```
> 
> d',' YYYY KK:mm:ss aa");  
> System.out.println(json);  
> String str = fmt.print(dt);
> 
> I got the following printout:
> 
> Oct 20, 2014 09:35:42 AM
> 
> which corresponds nicely to the data I try to index:  
> ...4","createdAt":"Oct 20, 2014 9:35:40 AM"... (just an extract from the  
> complete JSON document)
> 
> I changed the mapping for "createdAt" to "MMM d',' YYYY hh:mm:ss aa" BUT I  
> still get exactly the same error...
> 
> VERY frustrating...
> 
> Cheers
> 
> On Monday, October 20, 2014 9:06:44 AM UTC+2, Peter Litsegård wrote:
> 
> > Hi!
> > 
> > I've been struggling with two date formats. I'll give you a sample and  
> > the corresponding date format I've used:
> > 
> > 1. "Oct 20, 2014 8:42:41 AM" : MMM d YYYY hh:mm:ss aa
> > 2. "Mon Oct 20 06:42:41 +0000 2014" : EEE MMM d HH:mm:ss Z YYYY
> > 
> > I've used the following mapping:
> > 
> > {  
> > "settings" : {  
> > "index" : {  
> > "number\_of\_shards" : 1,  
> > "number\_of\_replicas" : 1  
> > }  
> > },  
> > "mappings" : {  
> > "envelope\_v1" : {  
> > "\_all" : { "enabled" : true },  
> > "\_id" : { "index" : "not\_analyzed", "store" : false, "path" :  
> > "id" },  
> > "\_timestamp" : { "enabled" : true, "path" : "createdAt" },  
> > "\_ttl" : { "enabled" : true, "default" : "30d" },  
> > "properties" : {  
> > "id" : { "type" : "string", "store" : false, "index" :  
> > "no" },  
> > "createdAt" : { "type" : "date", "format" : "MMM d YYYY  
> > hh:mm:ss aa", "store" : false, "index" : "no" },  
> > "ref" : { "type" : "string", "store" : false, "index" :  
> > "no" },  
> > "sourceType" : { "type" : "string", "store" : false,  
> > "index" : "no" },  
> > "search" : { "type" : "string", "store" : false, "index"  
> > : "no" },  
> > "source.created\_at" : { "type" : "date", "format" : "EEE  
> > MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> > "source.timestamp\_ms" : { "type" : "date", "store" :  
> > false, "index" : "no" },  
> > "source.user.created\_at" : { "type" : "date", "format" :  
> > "EEE MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> > "source.analysis.nlp" : { "type" : "object", "store" :  
> > false, "index" : "no" }  
> > }  
> > }  
> > }  
> > }
> > 
> > While adding data I get the following exception:
> > 
> > java.lang.IllegalArgumentException: Invalid format: "Mon Oct 20 06:30:52  
> > +0000 2014"  
> > at org.elasticsearch.common.joda.time.format.DateTimeFormatter.  
> > parseMillis(DateTimeFormatter.java:754)
> > 
> > What am I doing wrong here?
> > 
> > Cheers
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/71744ebf-91ad-4fbe-bc5e-b7aa3f457881%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/71744ebf-91ad-4fbe-bc5e-b7aa3f457881%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/71744ebf-91ad-4fbe-bc5e-b7aa3f457881%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/71744ebf-91ad-4fbe-bc5e-b7aa3f457881%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFY%3DCHihu97gGj%2B3Ds%3Dxk9q5LBWReFONg-U5rMmojyBEg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFY%3DCHihu97gGj%2B3Ds%3Dxk9q5LBWReFONg-U5rMmojyBEg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![kodo65](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodo65/32/1185_2.png) [@kodo65](https://discuss.elastic.co/u/kodo65)
#### Post date: [October 20, 2014, 8:06am UTC](https://discuss.elastic.co/t/joda-problem/20330/5 "2014-10-20T08:06:33Z")

</div>

Just to give you a sample.

Partial doc JSON:

{  
"id": "524107608429699072",  
"createdAt": "Oct 20, 2014 9:59:25 AM",  
"source": {  
"created\_at": "Mon Oct 20 07:59:25 +0000 2014",  
"source": "\<a href="[http://ElwynRoad.com](http://ElwynRoad.com)" rel="nofollow"\>Elwyn  
Road",  
"retweet\_count": 0,  
"retweeted": false,  
"filter\_level": "medium",  
"id\_str": "524107608429699072",  
...

As you can see "createdAt" conforms nicely to the following mapping:

{  
"settings" : {  
"index" : {  
"number\_of\_shards" : 1,  
"number\_of\_replicas" : 1  
}  
},  
"mappings" : {  
"envelope\_v1" : {  
"\_all" : { "enabled" : true },  
"\_id" : { "index" : "not\_analyzed", "store" : false, "path" :  
"id" },  
"\_timestamp" : { "enabled" : true, "path" : "createdAt" },  
"\_ttl" : { "enabled" : true, "default" : "30d" },  
"properties" : {  
"id" : { "type" : "string", "store" : false, "index" : "no"  
},  
"createdAt" : { "type" : "date", "format" : "MMM d',' YYYY  
KK:mm:ss aa", "store" : true, "index" : "no" },  
"ref" : { "type" : "string", "store" : false, "index" :  
"no" },  
"sourceType" : { "type" : "string", "store" : false,  
"index" : "no" },  
"search" : { "type" : "string", "store" : false, "index" :  
"no" },  
"source.created\_at" : { "type" : "date", "format" : "EEE  
MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
"source.timestamp\_ms" : { "type" : "date", "store" : false,  
"index" : "no" },  
"source.user.created\_at" : { "type" : "date", "format" :  
"EEE MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
"source.analysis.nlp" : { "type" : "object", "store" :  
false, "index" : "no" }  
}  
}  
}  
}

Still ES throws:

ElasticsearchParseException[failed to parse doc to extract  
routing/timestamp/id]; nested: TimestampParsingException[failed to parse  
timestamp [Oct 20, 2014 9:59:25 AM]];

Sigh...

On Monday, October 20, 2014 9:06:44 AM UTC+2, Peter Litsegård wrote:

> Hi!
> 
> I've been struggling with two date formats. I'll give you a sample and the  
> corresponding date format I've used:
> 
> 1. "Oct 20, 2014 8:42:41 AM" : MMM d YYYY hh:mm:ss aa
> 2. "Mon Oct 20 06:42:41 +0000 2014" : EEE MMM d HH:mm:ss Z YYYY
> 
> I've used the following mapping:
> 
> {  
> "settings" : {  
> "index" : {  
> "number\_of\_shards" : 1,  
> "number\_of\_replicas" : 1  
> }  
> },  
> "mappings" : {  
> "envelope\_v1" : {  
> "\_all" : { "enabled" : true },  
> "\_id" : { "index" : "not\_analyzed", "store" : false, "path" :  
> "id" },  
> "\_timestamp" : { "enabled" : true, "path" : "createdAt" },  
> "\_ttl" : { "enabled" : true, "default" : "30d" },  
> "properties" : {  
> "id" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "createdAt" : { "type" : "date", "format" : "MMM d YYYY  
> hh:mm:ss aa", "store" : false, "index" : "no" },  
> "ref" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "sourceType" : { "type" : "string", "store" : false,  
> "index" : "no" },  
> "search" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "source.created\_at" : { "type" : "date", "format" : "EEE  
> MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.timestamp\_ms" : { "type" : "date", "store" :  
> false, "index" : "no" },  
> "source.user.created\_at" : { "type" : "date", "format" :  
> "EEE MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.analysis.nlp" : { "type" : "object", "store" :  
> false, "index" : "no" }  
> }  
> }  
> }  
> }
> 
> While adding data I get the following exception:
> 
> java.lang.IllegalArgumentException: Invalid format: "Mon Oct 20 06:30:52  
> +0000 2014"  
> at  
> org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:754)
> 
> What am I doing wrong here?
> 
> Cheers

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8afad408-5c12-4831-80d5-83ea37294547%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8afad408-5c12-4831-80d5-83ea37294547%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![kodo65](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodo65/32/1185_2.png) [@kodo65](https://discuss.elastic.co/u/kodo65)
#### Post date: [October 20, 2014, 8:50am UTC](https://discuss.elastic.co/t/joda-problem/20330/6 "2014-10-20T08:50:11Z")

</div>

I decided to drop this for now and provide the timestamp field (createdAt)  
in milliseconds...

Thanks for your help though...

/Peter

On Monday, October 20, 2014 9:06:44 AM UTC+2, Peter Litsegård wrote:

> Hi!
> 
> I've been struggling with two date formats. I'll give you a sample and the  
> corresponding date format I've used:
> 
> 1. "Oct 20, 2014 8:42:41 AM" : MMM d YYYY hh:mm:ss aa
> 2. "Mon Oct 20 06:42:41 +0000 2014" : EEE MMM d HH:mm:ss Z YYYY
> 
> I've used the following mapping:
> 
> {  
> "settings" : {  
> "index" : {  
> "number\_of\_shards" : 1,  
> "number\_of\_replicas" : 1  
> }  
> },  
> "mappings" : {  
> "envelope\_v1" : {  
> "\_all" : { "enabled" : true },  
> "\_id" : { "index" : "not\_analyzed", "store" : false, "path" :  
> "id" },  
> "\_timestamp" : { "enabled" : true, "path" : "createdAt" },  
> "\_ttl" : { "enabled" : true, "default" : "30d" },  
> "properties" : {  
> "id" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "createdAt" : { "type" : "date", "format" : "MMM d YYYY  
> hh:mm:ss aa", "store" : false, "index" : "no" },  
> "ref" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "sourceType" : { "type" : "string", "store" : false,  
> "index" : "no" },  
> "search" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "source.created\_at" : { "type" : "date", "format" : "EEE  
> MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.timestamp\_ms" : { "type" : "date", "store" :  
> false, "index" : "no" },  
> "source.user.created\_at" : { "type" : "date", "format" :  
> "EEE MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.analysis.nlp" : { "type" : "object", "store" :  
> false, "index" : "no" }  
> }  
> }  
> }  
> }
> 
> While adding data I get the following exception:
> 
> java.lang.IllegalArgumentException: Invalid format: "Mon Oct 20 06:30:52  
> +0000 2014"  
> at  
> org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:754)
> 
> What am I doing wrong here?
> 
> Cheers

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1726a6b2-eebe-42ae-a3f6-16bf4c59e006%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1726a6b2-eebe-42ae-a3f6-16bf4c59e006%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [October 20, 2014, 9:06am UTC](https://discuss.elastic.co/t/joda-problem/20330/7 "2014-10-20T09:06:33Z")

</div>

I works here

PUT /myindex

PUT /myindex/test/\_mapping  
{  
"test": {  
"properties": {  
"created": {  
"type" : "date",  
"format" : "MMM d',' YYYY KK:mm:ss aa",  
"store" : true,  
"index" : "no"  
}  
}  
}  
}

PUT /myindex/test/1  
{  
"created" : "Oct 20, 2014 9:59:25 AM"  
}

GET /myindex/test/1

{  
"\_index": "myindex",  
"\_type": "test",  
"\_id": "1",  
"\_version": 1,  
"found": true,  
"\_source": {  
"created": "Oct 20, 2014 9:59:25 AM"  
}  
}

Jörg

On Mon, Oct 20, 2014 at 10:50 AM, Peter Litsegård \<  
[peter.litsegaard@gmail.com](mailto:peter.litsegaard@gmail.com)\> wrote:

> I decided to drop this for now and provide the timestamp field (createdAt)  
> in milliseconds...
> 
> Thanks for your help though...
> 
> /Peter
> 
> On Monday, October 20, 2014 9:06:44 AM UTC+2, Peter Litsegård wrote:
> 
> > Hi!
> > 
> > I've been struggling with two date formats. I'll give you a sample and  
> > the corresponding date format I've used:
> > 
> > 1. "Oct 20, 2014 8:42:41 AM" : MMM d YYYY hh:mm:ss aa
> > 2. "Mon Oct 20 06:42:41 +0000 2014" : EEE MMM d HH:mm:ss Z YYYY
> > 
> > I've used the following mapping:
> > 
> > {  
> > "settings" : {  
> > "index" : {  
> > "number\_of\_shards" : 1,  
> > "number\_of\_replicas" : 1  
> > }  
> > },  
> > "mappings" : {  
> > "envelope\_v1" : {  
> > "\_all" : { "enabled" : true },  
> > "\_id" : { "index" : "not\_analyzed", "store" : false, "path" :  
> > "id" },  
> > "\_timestamp" : { "enabled" : true, "path" : "createdAt" },  
> > "\_ttl" : { "enabled" : true, "default" : "30d" },  
> > "properties" : {  
> > "id" : { "type" : "string", "store" : false, "index" :  
> > "no" },  
> > "createdAt" : { "type" : "date", "format" : "MMM d YYYY  
> > hh:mm:ss aa", "store" : false, "index" : "no" },  
> > "ref" : { "type" : "string", "store" : false, "index" :  
> > "no" },  
> > "sourceType" : { "type" : "string", "store" : false,  
> > "index" : "no" },  
> > "search" : { "type" : "string", "store" : false, "index"  
> > : "no" },  
> > "source.created\_at" : { "type" : "date", "format" : "EEE  
> > MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> > "source.timestamp\_ms" : { "type" : "date", "store" :  
> > false, "index" : "no" },  
> > "source.user.created\_at" : { "type" : "date", "format" :  
> > "EEE MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> > "source.analysis.nlp" : { "type" : "object", "store" :  
> > false, "index" : "no" }  
> > }  
> > }  
> > }  
> > }
> > 
> > While adding data I get the following exception:
> > 
> > java.lang.IllegalArgumentException: Invalid format: "Mon Oct 20 06:30:52  
> > +0000 2014"  
> > at org.elasticsearch.common.joda.time.format.DateTimeFormatter.  
> > parseMillis(DateTimeFormatter.java:754)
> > 
> > What am I doing wrong here?
> > 
> > Cheers
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1726a6b2-eebe-42ae-a3f6-16bf4c59e006%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1726a6b2-eebe-42ae-a3f6-16bf4c59e006%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/1726a6b2-eebe-42ae-a3f6-16bf4c59e006%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/1726a6b2-eebe-42ae-a3f6-16bf4c59e006%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGt-vt%2BhN%3Da5VBG1fmpG%2BJcj%2BuU7LcBsYjCXcjLA9iPaQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGt-vt%2BhN%3Da5VBG1fmpG%2BJcj%2BuU7LcBsYjCXcjLA9iPaQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![kodo65](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodo65/32/1185_2.png) [@kodo65](https://discuss.elastic.co/u/kodo65)
#### Post date: [October 20, 2014, 9:08am UTC](https://discuss.elastic.co/t/joda-problem/20330/8 "2014-10-20T09:08:52Z")

</div>

Strange!!!! I decided to drop this for now due to a presentation tomorrow.  
Will pick it up afterwards...🙂

Cheers

On Monday, October 20, 2014 9:06:44 AM UTC+2, Peter Litsegård wrote:

> Hi!
> 
> I've been struggling with two date formats. I'll give you a sample and the  
> corresponding date format I've used:
> 
> 1. "Oct 20, 2014 8:42:41 AM" : MMM d YYYY hh:mm:ss aa
> 2. "Mon Oct 20 06:42:41 +0000 2014" : EEE MMM d HH:mm:ss Z YYYY
> 
> I've used the following mapping:
> 
> {  
> "settings" : {  
> "index" : {  
> "number\_of\_shards" : 1,  
> "number\_of\_replicas" : 1  
> }  
> },  
> "mappings" : {  
> "envelope\_v1" : {  
> "\_all" : { "enabled" : true },  
> "\_id" : { "index" : "not\_analyzed", "store" : false, "path" :  
> "id" },  
> "\_timestamp" : { "enabled" : true, "path" : "createdAt" },  
> "\_ttl" : { "enabled" : true, "default" : "30d" },  
> "properties" : {  
> "id" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "createdAt" : { "type" : "date", "format" : "MMM d YYYY  
> hh:mm:ss aa", "store" : false, "index" : "no" },  
> "ref" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "sourceType" : { "type" : "string", "store" : false,  
> "index" : "no" },  
> "search" : { "type" : "string", "store" : false, "index" :  
> "no" },  
> "source.created\_at" : { "type" : "date", "format" : "EEE  
> MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.timestamp\_ms" : { "type" : "date", "store" :  
> false, "index" : "no" },  
> "source.user.created\_at" : { "type" : "date", "format" :  
> "EEE MMM d HH:mm:ss Z YYYY", "store" : false, "index" : "no" },  
> "source.analysis.nlp" : { "type" : "object", "store" :  
> false, "index" : "no" }  
> }  
> }  
> }  
> }
> 
> While adding data I get the following exception:
> 
> java.lang.IllegalArgumentException: Invalid format: "Mon Oct 20 06:30:52  
> +0000 2014"  
> at  
> org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:754)
> 
> What am I doing wrong here?
> 
> Cheers

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2fa70c14-4d2c-42fe-b025-04d15f3bae0d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fa70c14-4d2c-42fe-b025-04d15f3bae0d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 12:55am UTC](https://discuss.elastic.co/t/joda-problem/20330/9 "2017-07-06T00:55:07Z")

</div>


