Skip to content

Commit

Permalink
Deprecate Util#RFC822_DATETIME_FORMATTER (#9085)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Mar 30, 2024
1 parent 8c2da85 commit f8a6ee5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
Expand Down Expand Up @@ -235,7 +238,7 @@ public static String localDate(Date date) {
}

public static String rfc822Date(Calendar cal) {
return Util.RFC822_DATETIME_FORMATTER.format(cal.getTime());
return DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant(cal.toInstant(), ZoneId.systemDefault()));
}

/**
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/hudson/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import java.text.ParseException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -1875,6 +1876,10 @@ public static void printRedirect(String contextPath, String redirectUrl, String
public static final FastDateFormat XS_DATETIME_FORMATTER = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss'Z'", new SimpleTimeZone(0, "GMT"));

// Note: RFC822 dates must not be localized!
/**
* @deprecated use {@link DateTimeFormatter#RFC_1123_DATE_TIME}
*/
@Deprecated
public static final FastDateFormat RFC822_DATETIME_FORMATTER
= FastDateFormat.getInstance("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);

Expand Down

0 comments on commit f8a6ee5

Please sign in to comment.