Skip to content

Commit

Permalink
Fix typo in date format (#26503)
Browse files Browse the repository at this point in the history
  • Loading branch information
kel authored and jpountz committed Sep 25, 2017
1 parent 1654d87 commit 32fb3f8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/elasticsearch/common/joda/Joda.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static FormatDateTimeFormatter forPattern(String input, Locale locale) {
formatter = ISODateTimeFormat.basicTime();
} else if ("basicTimeNoMillis".equals(input) || "basic_time_no_millis".equals(input)) {
formatter = ISODateTimeFormat.basicTimeNoMillis();
} else if ("basicTTime".equals(input) || "basic_t_Time".equals(input)) {
} else if ("basicTTime".equals(input) || "basic_t_time".equals(input)) {
formatter = ISODateTimeFormat.basicTTime();
} else if ("basicTTimeNoMillis".equals(input) || "basic_t_time_no_millis".equals(input)) {
formatter = ISODateTimeFormat.basicTTimeNoMillis();
Expand Down
53 changes: 53 additions & 0 deletions core/src/test/java/org/elasticsearch/common/joda/JodaTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.common.joda;

import org.elasticsearch.test.ESTestCase;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter;


public class JodaTests extends ESTestCase {


public void testBasicTTimePattern() {
FormatDateTimeFormatter formatter1 = Joda.forPattern("basic_t_time");
assertEquals(formatter1.format(), "basic_t_time");
DateTimeFormatter parser1 = formatter1.parser();

assertEquals(parser1.getZone(), DateTimeZone.UTC);

FormatDateTimeFormatter formatter2 = Joda.forPattern("basicTTime");
assertEquals(formatter2.format(), "basicTTime");
DateTimeFormatter parser2 = formatter2.parser();

assertEquals(parser2.getZone(), DateTimeZone.UTC);

DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, DateTimeZone.UTC);
assertEquals("T102030.040Z", parser1.print(dt));
assertEquals("T102030.040Z", parser2.print(dt));

expectThrows(IllegalArgumentException.class, () -> Joda.forPattern("basic_t_Time"));
expectThrows(IllegalArgumentException.class, () -> Joda.forPattern("basic_T_Time"));
expectThrows(IllegalArgumentException.class, () -> Joda.forPattern("basic_T_time"));
}

}

0 comments on commit 32fb3f8

Please sign in to comment.