|
|
@@ -69,14 +69,22 @@ public class DateFormatTests extends ESTestCase {
|
|
|
assertThat(dateTime.getYear(), is(year));
|
|
|
}
|
|
|
|
|
|
- public void testParseWeekBased() {
|
|
|
- String format = randomFrom("YYYY-ww");
|
|
|
+ public void testParseWeekBasedYearAndWeek() {
|
|
|
+ String format = "YYYY-ww";
|
|
|
ZoneId timezone = DateUtils.of("Europe/Amsterdam");
|
|
|
Function<String, ZonedDateTime> javaFunction = DateFormat.Java.getFunction(format, timezone, Locale.ROOT);
|
|
|
ZonedDateTime dateTime = javaFunction.apply("2020-33");
|
|
|
assertThat(dateTime, equalTo(ZonedDateTime.of(2020,8,10,0,0,0,0,timezone)));
|
|
|
}
|
|
|
|
|
|
+ public void testParseWeekBasedYear() {
|
|
|
+ String format = "YYYY";
|
|
|
+ ZoneId timezone = DateUtils.of("Europe/Amsterdam");
|
|
|
+ Function<String, ZonedDateTime> javaFunction = DateFormat.Java.getFunction(format, timezone, Locale.ROOT);
|
|
|
+ ZonedDateTime dateTime = javaFunction.apply("2019");
|
|
|
+ assertThat(dateTime, equalTo(ZonedDateTime.of(2018,12,31,0,0,0,0,timezone)));
|
|
|
+ }
|
|
|
+
|
|
|
public void testParseWeekBasedWithLocale() {
|
|
|
String format = randomFrom("YYYY-ww");
|
|
|
ZoneId timezone = DateUtils.of("Europe/Amsterdam");
|