Skip to content

Commit

Permalink
Fix deprecated suggestions for JodaCompatibleZonedDateTime (#83276)
Browse files Browse the repository at this point in the history
This updates the suggestions for getWeekyear and getWeekOfWeekyear in 
JodaCompatibleZonedDateTime to be correct within Painless.
  • Loading branch information
jdconrad committed Jan 28, 2022
1 parent 7749d6a commit a290d7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/83276.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 83276
summary: Fix deprecated suggestions for `JodaCompatibleZonedDateTime`
area: Infra/Scripting
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.DateFormatters;
import org.elasticsearch.common.time.DateUtils;
import org.elasticsearch.core.SuppressForbidden;
import org.joda.time.DateTime;
Expand All @@ -33,6 +32,7 @@
import java.time.chrono.Chronology;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.time.temporal.IsoFields;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalAdjuster;
Expand Down Expand Up @@ -470,14 +470,14 @@ public int getSecondOfMinute() {

@Deprecated
public int getWeekOfWeekyear() {
logDeprecatedMethod("getWeekOfWeekyear()", "get(DateFormatters.WEEK_FIELDS_ROOT.weekOfWeekBasedYear())");
return dt.get(DateFormatters.WEEK_FIELDS_ROOT.weekOfWeekBasedYear());
logDeprecatedMethod("getWeekOfWeekyear()", "get(IsoFields.WEEK_OF_WEEK_BASED_YEAR)");
return dt.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
}

@Deprecated
public int getWeekyear() {
logDeprecatedMethod("getWeekyear()", "get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())");
return dt.get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear());
logDeprecatedMethod("getWeekyear()", "get(IsoFields.WEEK_BASED_YEAR)");
return dt.get(IsoFields.WEEK_BASED_YEAR);
}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ public void testWeekOfWeekyear() {
assertMethodDeprecation(
() -> assertThat(javaTime.getWeekOfWeekyear(), equalTo(jodaTime.getWeekOfWeekyear())),
"getWeekOfWeekyear()",
"get(DateFormatters.WEEK_FIELDS_ROOT.weekOfWeekBasedYear())"
"get(IsoFields.WEEK_OF_WEEK_BASED_YEAR)"
);
}

public void testWeekyear() {
assertMethodDeprecation(
() -> assertThat(javaTime.getWeekyear(), equalTo(jodaTime.getWeekyear())),
"getWeekyear()",
"get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())"
"get(IsoFields.WEEK_BASED_YEAR)"
);
}

Expand Down

0 comments on commit a290d7b

Please sign in to comment.