Skip to content

Add missing ZonedDateTime methods for joda compat layer #44829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ class org.elasticsearch.script.JodaCompatibleZonedDateTime {
ZonedDateTime withZoneSameLocal(ZoneId)
ZonedDateTime withZoneSameInstant(ZoneId)

#### ChronoZonedDateTime
int compareTo(JodaCompatibleZonedDateTime)
Chronology getChronology()
String format(DateTimeFormatter)
int get(TemporalField)
long getLong(TemporalField)
ZoneOffset getOffset()
boolean isSupported(TemporalField)
long toEpochSecond()
LocalTime toLocalTime()

#### Joda methods that exist in java time
boolean equals(Object)
int hashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.chrono.Chronology;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAdjuster;
import java.time.temporal.TemporalAmount;
Expand Down Expand Up @@ -94,6 +98,42 @@ public String toString() {
return DATE_FORMATTER.format(dt);
}

public String format(DateTimeFormatter formatter) {
return dt.format(formatter);
}

public int get(TemporalField field) {
return dt.get(field);
}

public long getLong(TemporalField field) {
return dt.getLong(field);
}

public Chronology getChronology() {
return dt.getChronology();
}

public int compareTo(JodaCompatibleZonedDateTime o) {
return dt.compareTo(o.dt);
}

public ZoneOffset getOffset() {
return dt.getOffset();
}

public boolean isSupported(TemporalField field) {
return dt.isSupported(field);
}

public long toEpochSecond() {
return dt.toEpochSecond();
}

public LocalTime toLocalTime() {
return dt.toLocalTime();
}

public boolean isAfter(JodaCompatibleZonedDateTime o) {
return dt.isAfter(o.getZonedDateTime());
}
Expand All @@ -106,6 +146,8 @@ public boolean isEqual(JodaCompatibleZonedDateTime o) {
return dt.isEqual(o.getZonedDateTime());
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: empty line?


public int getDayOfMonth() {
return dt.getDayOfMonth();
}
Expand Down