Add getZone to JodaCompatibleZonedDateTime (#37084)

The ZonedDateTime#getZone() was not accessible via the Joda shim. This
commit adds getZone() and exposes it through painless.
This commit is contained in:
Michael Basnight 2019-01-09 22:09:34 -06:00 committed by GitHub
parent 586093ec5e
commit d625b79df2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -87,6 +87,7 @@ class org.elasticsearch.script.JodaCompatibleZonedDateTime {
int getNano()
int getSecond()
int getYear()
ZoneId getZone()
ZonedDateTime minus(TemporalAmount)
ZonedDateTime minus(long,TemporalUnit)
ZonedDateTime minusYears(long)

View File

@ -151,6 +151,10 @@ public class JodaCompatibleZonedDateTime {
return dt.getYear();
}
public ZoneId getZone() {
return dt.getZone();
}
public ZonedDateTime minus(TemporalAmount delta) {
return dt.minus(delta);
}

View File

@ -152,6 +152,10 @@ public class JodaCompatibleZonedDateTimeTests extends ESTestCase {
assertThat(javaTime.getYear(), equalTo(jodaTime.getYear()));
}
public void testZone() {
assertThat(javaTime.getZone().getId(), equalTo(jodaTime.getZone().getID()));
}
public void testMillis() {
assertMethodDeprecation(() -> assertThat(javaTime.getMillis(), equalTo(jodaTime.getMillis())),
"getMillis()", "toInstant().toEpochMilli()");