From cde62a69e1b485fcdde677bdf7808531e7b32f1f Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Fri, 4 Mar 2011 13:42:49 +0000 Subject: [PATCH] Use private UTC constant to avoid corruption of mutable constant git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1077943 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/lang3/time/DateFormatUtils.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java b/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java index f7289ca00..be6c93165 100644 --- a/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java @@ -37,6 +37,11 @@ import java.util.TimeZone; */ public class DateFormatUtils { + /** + * The UTC time zone (often referred to as GMT). + * This is private as it is mutable. + */ + private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("GMT"); /** * ISO8601 formatter for date-time without time zone. * The format used is yyyy-MM-dd'T'HH:mm:ss. @@ -125,7 +130,7 @@ public class DateFormatUtils { * @return the formatted date */ public static String formatUTC(long millis, String pattern) { - return format(new Date(millis), pattern, DateUtils.UTC_TIME_ZONE, null); + return format(new Date(millis), pattern, UTC_TIME_ZONE, null); } /** @@ -136,7 +141,7 @@ public class DateFormatUtils { * @return the formatted date */ public static String formatUTC(Date date, String pattern) { - return format(date, pattern, DateUtils.UTC_TIME_ZONE, null); + return format(date, pattern, UTC_TIME_ZONE, null); } /** @@ -148,7 +153,7 @@ public class DateFormatUtils { * @return the formatted date */ public static String formatUTC(long millis, String pattern, Locale locale) { - return format(new Date(millis), pattern, DateUtils.UTC_TIME_ZONE, locale); + return format(new Date(millis), pattern, UTC_TIME_ZONE, locale); } /** @@ -160,7 +165,7 @@ public class DateFormatUtils { * @return the formatted date */ public static String formatUTC(Date date, String pattern, Locale locale) { - return format(date, pattern, DateUtils.UTC_TIME_ZONE, locale); + return format(date, pattern, UTC_TIME_ZONE, locale); } /**