]> granicus.if.org Git - icu/commitdiff
ICU-10615 Updated the fix by adding an intenal API Calendar.haveDefaultCentury()...
authorYoshito Umaoka <y.umaoka@gmail.com>
Fri, 10 Jan 2014 21:45:57 +0000 (21:45 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Fri, 10 Jan 2014 21:45:57 +0000 (21:45 +0000)
X-SVN-Rev: 34868

icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java
icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java
icu4j/main/classes/core/src/com/ibm/icu/util/ChineseCalendar.java
icu4j/main/classes/core/src/com/ibm/icu/util/JapaneseCalendar.java

index ffff47451a31a87835de20bf630bfa0e1fa72283..72368613e5d860c4e0e6f304433b46f2876ce3e1 100644 (file)
@@ -2819,7 +2819,7 @@ public class SimpleDateFormat extends DateFormat {
                 /* Skip this for Chinese calendar, moved from ChineseDateFormat */
                 if ( override != null && (override.compareTo("hebr") == 0 || override.indexOf("y=hebr") >= 0) && value < 1000 ) {
                     value += HEBREW_CAL_CUR_MILLENIUM_START_YEAR;
-                } else if (count == 2 && (pos.getIndex() - start) == 2 && !isChineseCalendar && !cal.getType().equals("japanese")
+                } else if (count == 2 && (pos.getIndex() - start) == 2 && cal.haveDefaultCentury()
                     && UCharacter.isDigit(text.charAt(start))
                     && UCharacter.isDigit(text.charAt(start+1)))
                     {
index 06dc781e61dc9d192942461443e0ddc9f2d6c695..fe24a29e438d2ee482ba5da0c7553efaeb88fc3d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*   Copyright (C) 1996-2013, International Business Machines
+*   Copyright (C) 1996-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 */
 
@@ -6080,6 +6080,21 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
         return "unknown";
     }
 
+    /**
+     * Returns if two digit representation of year in this calendar type
+     * customarily implies a default century (i.e. 03 -> 2003).
+     * The default implementation returns <code>true</code>. A subclass may
+     * return <code>false</code> if such practice is not applicable (for example,
+     * Chinese calendar and Japanese calendar).
+     * 
+     * @return <code>true<code> if this calendar has a default century.
+     * @internal
+     * @deprecated This API is ICU internal only.
+     */
+    public boolean haveDefaultCentury() {
+        return true;
+    }
+
     // -------- BEGIN ULocale boilerplate --------
 
     /**
index 1cdfe2f79d18e8ddfb45046be4996d7292d522bf..6c69e6d785eb215cbca585b5fbfa0939224e9455 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- * Copyright (C) 2000-2012, International Business Machines
+ * Copyright (C) 2000-2014, International Business Machines
  * Corporation and others. All Rights Reserved.
  *********************************************************************
  */
@@ -1017,6 +1017,15 @@ public class ChineseCalendar extends Calendar {
         return "chinese";
     }
 
+    /**
+     * {@inheritDoc}
+     * @internal
+     * @deprecated This API is ICU internal only.
+     */
+    public boolean haveDefaultCentury() {
+        return false;
+    }
+
     /**
      * Override readObject.
      */
index 9e71a79a272365ad1b37a78aa2fedf870188f219..f88fed9e98ab989f7a9c925dd8e2c781dd0d2aa0 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (C) 1996-2010,2012, International Business Machines Corporation and    *
+ * Copyright (C) 1996-2014, International Business Machines Corporation and    *
  * others. All Rights Reserved.                                                *
  *******************************************************************************
  */
@@ -636,6 +636,15 @@ public class JapaneseCalendar extends GregorianCalendar {
         return "japanese";
     }
 
+    /**
+     * {@inheritDoc}
+     * @internal
+     * @deprecated This API is ICU internal only.
+     */
+    public boolean haveDefaultCentury() {
+        return false;
+    }
+
     /**
      * {@inheritDoc}
      * @stable ICU 4.0
@@ -661,4 +670,5 @@ public class JapaneseCalendar extends GregorianCalendar {
         }
         return super.getActualMaximum(field);
     }
+
 }