This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/turbine-core.git
The following commit(s) were added to refs/heads/trunk by this push:
new e1bdece1 Use java.time.format.DateTimeFormatter
e1bdece1 is described below
commit e1bdece1208cc78857b3488d10ce618270dc9765
Author: Thomas Vandahl <[email protected]>
AuthorDate: Thu Jan 8 21:22:59 2026 +0100
Use java.time.format.DateTimeFormatter
---
src/java/org/apache/turbine/util/HttpUtils.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/java/org/apache/turbine/util/HttpUtils.java
b/src/java/org/apache/turbine/util/HttpUtils.java
index 84d3fcbc..2cab149d 100644
--- a/src/java/org/apache/turbine/util/HttpUtils.java
+++ b/src/java/org/apache/turbine/util/HttpUtils.java
@@ -19,13 +19,14 @@ package org.apache.turbine.util;
* under the License.
*/
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
-import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.turbine.Turbine;
import org.apache.turbine.pipeline.PipelineData;
@@ -36,7 +37,6 @@ import jakarta.servlet.http.HttpServletResponse;
* would otherwise be handled elsewhere.
*
* @author <a href="mailto:[email protected]">Magnús Þór Torfason</a>
- * @version $Id$
*/
public class HttpUtils
{
@@ -50,10 +50,10 @@ public class HttpUtils
/**
* The date format to use for HTTP Dates.
*/
- private static FastDateFormat httpDateFormat = FastDateFormat.getInstance(
- "EEE, dd MMM yyyy HH:mm:ss z",
- TimeZone.getTimeZone("GMT"),
- Locale.US);
+ private static DateTimeFormatter HTTP_DATE_FORMATTER =
+ DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z")
+ .withZone(ZoneId.of("GMT"))
+ .withLocale(Locale.US);
/**
* Formats a java Date according to rfc 1123, the rfc standard for dates in
@@ -64,7 +64,8 @@ public class HttpUtils
*/
public static String formatHttpDate(Date date)
{
- return httpDateFormat.format(date);
+ return HTTP_DATE_FORMATTER.format(
+ ZonedDateTime.ofInstant(date.toInstant(), ZoneId.of("GMT")));
}
/**