Author: scolebourne
Date: Fri Mar  4 13:42:49 2011
New Revision: 1077943

URL: http://svn.apache.org/viewvc?rev=1077943&view=rev
Log:
Use private UTC constant to avoid corruption of mutable constant

Modified:
    
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java

Modified: 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java
URL: 
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java?rev=1077943&r1=1077942&r2=1077943&view=diff
==============================================================================
--- 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java
 (original)
+++ 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java
 Fri Mar  4 13:42:49 2011
@@ -38,6 +38,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 <tt>yyyy-MM-dd'T'HH:mm:ss</tt>.
      */
@@ -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);
     }
     
     /**


Reply via email to