Date detection for `YYYY/MM/dd` or `YYYY/MM/dd HH:mm:ss` without timezones now broken, closes #1241.

This commit is contained in:
Shay Banon 2011-08-13 13:08:12 +03:00
parent 3b987f9ee0
commit 252ba57703
2 changed files with 12 additions and 3 deletions

View File

@ -51,7 +51,7 @@ public class RootObjectMapper extends ObjectMapper {
public static final FormatDateTimeFormatter[] DYNAMIC_DATE_TIME_FORMATTERS =
new FormatDateTimeFormatter[]{
DateFieldMapper.Defaults.DATE_TIME_FORMATTER,
Joda.forPattern("yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z")
Joda.forPattern("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd")
};
public static final boolean DATE_DETECTION = true;
public static final boolean NUMERIC_DETECTION = false;

View File

@ -42,12 +42,21 @@ public class SimpleDateMappingTests {
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
.startObject()
.field("date_field", "2011/01/22 00:00:00 +02")
.field("date_field1", "2011/01/22")
.field("date_field2", "2011/01/22 00:00:00")
// .field("date_field3", "2011/01/22 +02")
// .field("date_field4", "2011/01/22 00:00:00 +02:00")
.endObject()
.copiedBytes());
FieldMapper fieldMapper = defaultMapper.mappers().smartNameFieldMapper("date_field");
FieldMapper fieldMapper = defaultMapper.mappers().smartNameFieldMapper("date_field1");
assertThat(fieldMapper, instanceOf(DateFieldMapper.class));
fieldMapper = defaultMapper.mappers().smartNameFieldMapper("date_field2");
assertThat(fieldMapper, instanceOf(DateFieldMapper.class));
// fieldMapper = defaultMapper.mappers().smartNameFieldMapper("date_field3");
// assertThat(fieldMapper, instanceOf(DateFieldMapper.class));
// fieldMapper = defaultMapper.mappers().smartNameFieldMapper("date_field4");
// assertThat(fieldMapper, instanceOf(DateFieldMapper.class));
}
@Test public void testTimestampAsDate() throws Exception {