commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1477507 - in /commons/proper/lang/trunk/src: changes/changes.xml main/java/org/apache/commons/lang3/time/FastDateFormat.java main/java/org/apache/commons/lang3/time/FormatCache.java
Date Tue, 30 Apr 2013 08:40:58 GMT
Author: sebb
Date: Tue Apr 30 08:40:58 2013
New Revision: 1477507

URL: http://svn.apache.org/r1477507
Log:
LANG-884 Simplify FastDateFormat; eliminate boxing

Modified:
    commons/proper/lang/trunk/src/changes/changes.xml
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java

Modified: commons/proper/lang/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1477507&r1=1477506&r2=1477507&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/changes/changes.xml (original)
+++ commons/proper/lang/trunk/src/changes/changes.xml Tue Apr 30 08:40:58 2013
@@ -22,7 +22,8 @@
   <body>
 
   <release version="3.2" date="TBA" description="Next release">
-    <action issue="LANG-882" type="update">LookupTranslator now works with implementations
of CharSequence other than String </action>
+    <action issue="LANG-884" type="update">Simplify FastDateFormat; eliminate boxing</action>
+    <action issue="LANG-882" type="update">LookupTranslator now works with implementations
of CharSequence other than String</action>
     <action issue="LANG-754" type="fix">ClassUtils.getShortName(String) will now only
do a reverse lookup for array types</action>  
     <action issue="LANG-886" type="add">Added CharSetUtils.containsAny(String, String)</action>
     <action issue="LANG-846" type="update">Provide CharSequenceUtils.regionMatches
with a proper green implementation instead of inefficiently converting to Strings</action>

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java?rev=1477507&r1=1477506&r2=1477507&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
Tue Apr 30 08:40:58 2013
@@ -177,7 +177,7 @@ public class FastDateFormat extends Form
      * @since 2.1
      */
     public static FastDateFormat getDateInstance(final int style) {
-        return cache.getDateTimeInstance(style, null, null, null);
+        return cache.getDateInstance(style, null, null);
     }
 
     /**
@@ -192,7 +192,7 @@ public class FastDateFormat extends Form
      * @since 2.1
      */
     public static FastDateFormat getDateInstance(final int style, final Locale locale) {
-        return cache.getDateTimeInstance(style, null, null, locale);
+        return cache.getDateInstance(style, null, locale);
     }
 
     /**
@@ -208,7 +208,7 @@ public class FastDateFormat extends Form
      * @since 2.1
      */
     public static FastDateFormat getDateInstance(final int style, final TimeZone timeZone)
{
-        return cache.getDateTimeInstance(style, null, timeZone, null);
+        return cache.getDateInstance(style, timeZone, null);
     }
     
     /**
@@ -224,7 +224,7 @@ public class FastDateFormat extends Form
      *  pattern defined
      */
     public static FastDateFormat getDateInstance(final int style, final TimeZone timeZone,
final Locale locale) {
-        return cache.getDateTimeInstance(style, null, timeZone, locale);
+        return cache.getDateInstance(style, timeZone, locale);
     }
 
     //-----------------------------------------------------------------------
@@ -239,7 +239,7 @@ public class FastDateFormat extends Form
      * @since 2.1
      */
     public static FastDateFormat getTimeInstance(final int style) {
-        return cache.getDateTimeInstance(null, style, null, null);
+        return cache.getTimeInstance(style, null, null);
     }
 
     /**
@@ -254,7 +254,7 @@ public class FastDateFormat extends Form
      * @since 2.1
      */
     public static FastDateFormat getTimeInstance(final int style, final Locale locale) {
-        return cache.getDateTimeInstance(null, style, null, locale);
+        return cache.getTimeInstance(style, null, locale);
     }
 
     /**
@@ -270,7 +270,7 @@ public class FastDateFormat extends Form
      * @since 2.1
      */
     public static FastDateFormat getTimeInstance(final int style, final TimeZone timeZone)
{
-        return cache.getDateTimeInstance(null, style, timeZone, null);
+        return cache.getTimeInstance(style, timeZone, null);
     }
 
     /**
@@ -286,7 +286,7 @@ public class FastDateFormat extends Form
      *  pattern defined
      */
     public static FastDateFormat getTimeInstance(final int style, final TimeZone timeZone,
final Locale locale) {
-        return cache.getDateTimeInstance(null, style, timeZone, locale);
+        return cache.getTimeInstance(style, timeZone, locale);
     }
 
     //-----------------------------------------------------------------------

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java?rev=1477507&r1=1477506&r2=1477507&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java
Tue Apr 30 08:40:58 2013
@@ -116,7 +116,8 @@ abstract class FormatCache<F extends For
      * @throws IllegalArgumentException if the Locale has no date/time
      *  pattern defined
      */
-    public F getDateTimeInstance(final Integer dateStyle, final Integer timeStyle, final
TimeZone timeZone, Locale locale) {
+    // This must remain private, see LANG-884 
+    private F getDateTimeInstance(final Integer dateStyle, final Integer timeStyle, final
TimeZone timeZone, Locale locale) {
         if (locale == null) {
             locale = Locale.getDefault();
         }
@@ -124,6 +125,59 @@ abstract class FormatCache<F extends For
         return getInstance(pattern, timeZone, locale);
     }
 
+    /*
+     * <p>Gets a date/time formatter instance using the specified style,
+     * time zone and locale.</p>
+     * 
+     * @param dateStyle  date style: FULL, LONG, MEDIUM, or SHORT
+     * @param timeStyle  time style: FULL, LONG, MEDIUM, or SHORT
+     * @param timeZone  optional time zone, overrides time zone of
+     *  formatted date, null means use default Locale
+     * @param locale  optional locale, overrides system locale
+     * @return a localized standard date/time formatter
+     * @throws IllegalArgumentException if the Locale has no date/time
+     *  pattern defined
+     */
+    // package protected, for access from FastDateFormat; do not make public or protected
+    F getDateTimeInstance(final int dateStyle, final int timeStyle, final TimeZone timeZone,
Locale locale) {
+        return getDateTimeInstance(Integer.valueOf(dateStyle), Integer.valueOf(timeStyle),
timeZone, locale);
+    }
+
+    /*
+     * <p>Gets a date formatter instance using the specified style,
+     * time zone and locale.</p>
+     * 
+     * @param dateStyle  date style: FULL, LONG, MEDIUM, or SHORT
+     * @param timeZone  optional time zone, overrides time zone of
+     *  formatted date, null means use default Locale
+     * @param locale  optional locale, overrides system locale
+     * @return a localized standard date/time formatter
+     * @throws IllegalArgumentException if the Locale has no date/time
+     *  pattern defined
+     */
+    // package protected, for access from FastDateFormat; do not make public or protected
+    F getDateInstance(final int dateStyle, final TimeZone timeZone, Locale locale) {
+        return getDateTimeInstance(Integer.valueOf(dateStyle), null, timeZone, locale);
+    }
+
+    /*
+     * <p>Gets a time formatter instance using the specified style,
+     * time zone and locale.</p>
+     * 
+     * @param dateStyle  date style: FULL, LONG, MEDIUM, or SHORT
+     * @param timeStyle  time style: FULL, LONG, MEDIUM, or SHORT
+     * @param timeZone  optional time zone, overrides time zone of
+     *  formatted date, null means use default Locale
+     * @param locale  optional locale, overrides system locale
+     * @return a localized standard date/time formatter
+     * @throws IllegalArgumentException if the Locale has no date/time
+     *  pattern defined
+     */
+    // package protected, for access from FastDateFormat; do not make public or protected
+    F getTimeInstance(final int timeStyle, final TimeZone timeZone, Locale locale) {
+        return getDateTimeInstance(null, Integer.valueOf(timeStyle), timeZone, locale);
+    }
+
     /**
      * <p>Gets a date/time format for the specified styles and locale.</p>
      * 
@@ -133,7 +187,8 @@ abstract class FormatCache<F extends For
      * @return a localized standard date/time format
      * @throws IllegalArgumentException if the Locale has no date/time pattern defined
      */
-    public static String getPatternForStyle(final Integer dateStyle, final Integer timeStyle,
final Locale locale) {
+    // package protected, for access from test code; do not make public or protected
+    static String getPatternForStyle(final Integer dateStyle, final Integer timeStyle, final
Locale locale) {
         final MultipartKey key = new MultipartKey(dateStyle, timeStyle, locale);
 
         String pattern = cDateTimeInstanceCache.get(key);



Mime
View raw message