ICU-9231 Merged two fixes - #10615(r34830/r34868) TestConsistentPivot and #10937(r35804) TestTwoDigitYear from trunk.

X-SVN-Rev: 37555
This commit is contained in:
Yoshito Umaoka 2015-06-15 15:54:59 +00:00
parent ecd08d033e
commit e8aa6ffe4e
5 changed files with 44 additions and 10 deletions

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2012, International Business Machines Corporation and *
* Copyright (C) 1996-2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -2236,7 +2236,7 @@ public class SimpleDateFormat extends DateFormat {
// is treated literally: "2250", "-1", "1", "002".
/* 'yy' is the only special case, 'y' is interpreted as number. [Richard/GCL]*/
/* Skip this for Chinese calendar, moved from ChineseDateFormat */
if (count == 2 && (pos.getIndex() - start) == 2 && !cal.getType().equals("chinese")
if (count == 2 && (pos.getIndex() - start) == 2 && cal.haveDefaultCentury()
&& UCharacter.isDigit(text.charAt(start))
&& UCharacter.isDigit(text.charAt(start+1)))
{

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 1996-2012, International Business Machines
* Copyright (C) 1996-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*/
@ -5941,6 +5941,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 --------
/**

View file

@ -1,5 +1,5 @@
/*********************************************************************
* Copyright (C) 2000-2012, International Business Machines
* Copyright (C) 2000-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*********************************************************************
*/
@ -1023,6 +1023,15 @@ public class ChineseCalendar extends Calendar {
return "chinese";
}
/**
* {@inheritDoc}
* @internal
* @deprecated This API is ICU internal only.
*/
public boolean haveDefaultCentury() {
return false;
}
/**
* Override readObject.
*/

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* Copyright (C) 1996-2015, 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);
}
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2001-2012, International Business Machines Corporation and *
* Copyright (C) 2001-2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -1831,11 +1831,11 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(117 + 1900, Calendar.JUNE, 5);
parse2DigitYear(fmt, "6/5/17", cal.getTime());
cal.set(130 + 1900, Calendar.JUNE, 5);
parse2DigitYear(fmt, "6/5/30", cal.getTime());
cal.clear();
cal.set(34 + 1900, Calendar.JUNE, 4);
parse2DigitYear(fmt, "6/4/34", cal.getTime());
cal.set(50 + 1900, Calendar.JUNE, 4);
parse2DigitYear(fmt, "6/4/50", cal.getTime());
}
// internal test subroutine, used by TestTwoDigitYear