ICU-5801 Merging bug fixes (#5553, #5596, #5910, #5887, #5915, #5917, #5921) from trunk to main-3-8 for ICU4J 3.8 release.

X-SVN-Rev: 22644
This commit is contained in:
Yoshito Umaoka 2007-09-07 21:56:02 +00:00
parent 668bb96bfd
commit db35e6edec
14 changed files with 220 additions and 114 deletions

View file

@ -98,6 +98,7 @@ class CharsetISCII extends CharsetICU {
private final String ISCII_CNV_PREFIX = "ISCII,version=";
private final class UConverterDataISCII {
int option;
int contextCharToUnicode; /* previous Unicode codepoint for contextual analysis */
int contextCharFromUnicode; /* previous Unicode codepoint for contextual analysis */
short defDeltaToUnicode; /* delta for switching to default state when DEF is encountered */
@ -110,20 +111,24 @@ class CharsetISCII extends CharsetICU {
boolean resetToDefaultToUnicode; /* boolean for reseting to default delta and mask when a newline is encountered */
String name;
UConverterDataISCII(int contextCharToUnicode, int contextCharFromUnicode, short defDeltaToUnicode, short currentDeltaFromUnicode,
short currentDeltaToUnicode, short currentMaskFromUnicode, short currentMaskToUnicode, short defMaskToUnicode,
boolean isFirstBuffer, boolean resetToDefaultToUnicode, String name) {
this.contextCharToUnicode = contextCharToUnicode;
this.contextCharFromUnicode = contextCharFromUnicode;
this.defDeltaToUnicode = defDeltaToUnicode;
this.currentDeltaFromUnicode = currentDeltaFromUnicode;
this.currentDeltaToUnicode = currentDeltaToUnicode;
this.currentMaskFromUnicode = currentMaskFromUnicode;
this.currentMaskToUnicode = currentMaskToUnicode;
this.defMaskToUnicode = defMaskToUnicode;
this.isFirstBuffer = isFirstBuffer;
this.resetToDefaultToUnicode = resetToDefaultToUnicode;
UConverterDataISCII(int option, String name) {
this.option = option;
this.name = name;
initialize();
}
void initialize() {
this.contextCharToUnicode = NO_CHAR_MARKER; /* contextCharToUnicode */
this.currentDeltaFromUnicode = 0x0000; /* contextCharFromUnicode */
this.defDeltaToUnicode = (short)(lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].uniLang * UniLang.DELTA); /* defDeltaToUnicode */
this.currentDeltaFromUnicode = (short)(lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].uniLang * UniLang.DELTA); /* currentDeltaFromUnicode */
this.currentDeltaToUnicode = (short)(lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].uniLang * UniLang.DELTA); /* currentDeltaToUnicode */
this.currentMaskToUnicode = (short)lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].maskEnum; /* currentMaskToUnicode */
this.currentMaskFromUnicode = (short)lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].maskEnum; /* currentMaskFromUnicode */
this.defMaskToUnicode = (short)lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].maskEnum; /* defMaskToUnicode */
this.isFirstBuffer = true; /* isFirstBuffer */
this.resetToDefaultToUnicode = false; /* resetToDefaultToUnicode */
}
}
@ -729,17 +734,8 @@ class CharsetISCII extends CharsetICU {
//get the version number of the ISCII converter
int option = Integer.parseInt(icuCanonicalName.substring(14));
extraInfo = new UConverterDataISCII(
NO_CHAR_MARKER, /* contextCharToUnicode */
0x0000, /* contextCharFromUnicode */
(short)(lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].uniLang * UniLang.DELTA), /* defDeltaToUnicode */
(short)(lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].uniLang * UniLang.DELTA), /* currentDeltaFromUnicode */
(short)(lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].uniLang * UniLang.DELTA), /* currentDeltaToUnicode */
(short)lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].maskEnum, /* currentMaskToUnicode */
(short)lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].maskEnum, /* currentMaskFromUnicode */
(short)lookupInitialData[option & UCNV_OPTIONS_VERSION_MASK].maskEnum, /* defMaskToUnicode */
true, /* isFirstBuffer */
false, /* resetToDefaultToUnicode */
extraInfo = new UConverterDataISCII(
option,
new String(ISCII_CNV_PREFIX + (option & UCNV_OPTIONS_VERSION_MASK)) /* name */
);
}
@ -772,6 +768,7 @@ class CharsetISCII extends CharsetICU {
protected void implReset() {
super.implReset();
this.toUnicodeStatus = 0xFFFF;
extraInfo.initialize();
}
protected CoderResult decodeLoop(ByteBuffer source, CharBuffer target, IntBuffer offsets, boolean flush) {
@ -1069,6 +1066,7 @@ class CharsetISCII extends CharsetICU {
protected void implReset() {
super.implReset();
extraInfo.initialize();
}
protected CoderResult encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush) {

View file

@ -1,7 +1,7 @@
//##header J2SE15
/**
*******************************************************************************
* Copyright (C) 2005-2006, International Business Machines Corporation and *
* Copyright (C) 2005-2007, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -311,6 +311,29 @@ public class TestCharsetDetector extends TestFmwk
}
}
public void TestShortInput() {
// Test that detection with very short byte strings does not crash and burn.
// The shortest input that should produce positive detection result is two bytes,
// a UTF-16 BOM.
// TODO: Detector confidence levels needs to be refined for very short input.
// Too high now, for some charsets that happen to be compatible with a few bytes of input.
byte [][] shortBytes = new byte [][]
{
{},
{(byte)0x0a},
{(byte)'A', (byte)'B'},
{(byte)'A', (byte)'B', (byte)'C'},
{(byte)'A', (byte)'B', (byte)'C', (byte)'D'}
};
CharsetDetector det = new CharsetDetector();
CharsetMatch m;
for (int i=0; i<shortBytes.length; i++) {
det.setText(shortBytes[i]);
m = det.detect();
}
}
public void TestDetection()
{
//

View file

@ -410,8 +410,9 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
"y/M/d H:mm v", "pf", "2004/10/31 1:30 PST", "2004 10 31 01:30 PST", "2004/10/31 1:30 PT",
"y/M/d H:mm v", "pf", "2004/10/31 1:30 PDT", "2004 10 31 01:30 PDT", "2004/10/31 1:30 PT",
"y/M/d H:mm", "pf", "2004/10/31 1:30", "2004 10 31 01:30 PST", "2004/10/31 1:30",
"y/M/d H:mm vvvv", "pf", "2004/10/31 1:30 Argentina (Buenos Aires)", "2004 10 30 21:30 PDT", "2004/10/31 1:30 Argentina (Buenos Aires)",
// Below is actually an invalid test case. See the note in #5910. Disable the case for now.
// TODO: Revisit after 3.8
//"y/M/d H:mm vvvv", "pf", "2004/10/31 1:30 Argentina Time", "2004 10 30 21:30 PDT", "2004/10/31 1:30 Argentina Time",
};
expect(ZDATA, en);
@ -533,6 +534,19 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
{ "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "vvvv", "Pacific Time", "America/Los_Angeles" },
{ "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "VVVV", "United States (Los Angeles)", "America/Los_Angeles" },
{ "en_GB", "America/Los_Angeles", "2004-01-15T12:00:00Z", "z", "PST", "America/Los_Angeles" },
{ "en", "America/Phoenix", "2004-01-15T00:00:00Z", "Z", "-0700", "-7:00" },
{ "en", "America/Phoenix", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-07:00", "-7:00" },
{ "en", "America/Phoenix", "2004-01-15T00:00:00Z", "z", "MST", "America/Phoenix" },
{ "en", "America/Phoenix", "2004-01-15T00:00:00Z", "V", "MST", "America/Phoenix" },
{ "en", "America/Phoenix", "2004-01-15T00:00:00Z", "zzzz", "Mountain Standard Time", "America/Phoenix" },
{ "en", "America/Phoenix", "2004-07-15T00:00:00Z", "Z", "-0700", "-7:00" },
{ "en", "America/Phoenix", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-07:00", "-7:00" },
{ "en", "America/Phoenix", "2004-07-15T00:00:00Z", "z", "MST", "America/Phoenix" },
{ "en", "America/Phoenix", "2004-07-15T00:00:00Z", "V", "MST", "America/Phoenix" },
{ "en", "America/Phoenix", "2004-07-15T00:00:00Z", "zzzz", "Mountain Standard Time", "America/Phoenix" },
{ "en", "America/Phoenix", "2004-07-15T00:00:00Z", "v", "MST", "America/Phoenix" },
{ "en", "America/Phoenix", "2004-07-15T00:00:00Z", "vvvv", "Mountain Standard Time", "America/Phoenix" },
{ "en", "America/Phoenix", "2004-07-15T00:00:00Z", "VVVV", "United States (Phoenix)", "America/Phoenix" },
{ "en", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
{ "en", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
@ -545,7 +559,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
{ "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "V", "ART", "-3:00" },
{ "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "Argentina Time", "-3:00" },
{ "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "Argentina (Buenos Aires)", "America/Buenos_Aires" },
{ "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "Argentina (Buenos Aires)", "America/Buenos_Aires" },
{ "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "Argentina Time", "America/Buenos_Aires" },
{ "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "VVVV", "Argentina (Buenos Aires)", "America/Buenos_Aires" },
{ "en", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
@ -559,7 +573,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
{ "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "V", "ART", "-3:00" },
{ "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "Argentina Time", "-3:00" },
{ "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "Argentina (Buenos Aires)", "America/Buenos_Aires" },
{ "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "Argentina (Buenos Aires)", "America/Buenos_Aires" },
{ "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "Argentina Time", "America/Buenos_Aires" },
{ "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "VVVV", "Argentina (Buenos Aires)", "America/Buenos_Aires" },
{ "en", "America/Havana", "2004-01-15T00:00:00Z", "Z", "-0500", "-5:00" },
@ -642,7 +656,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
{ "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "V", "IST", "+05:30" },
{ "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "India Standard Time", "+5:30" },
{ "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "India Time", "Asia/Calcutta" },
{ "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "India Time", "Asia/Calcutta" },
{ "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "India Standard Time", "Asia/Calcutta" },
// ==========
@ -955,8 +969,8 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
{ "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+\u0966\u096B:\u0969\u0966", "+5:30" },
{ "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "z", "IST", "+05:30" },
{ "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "\u092D\u093E\u0930\u0924\u0940\u092F \u0938\u092E\u092F", "+5:30" },
{ "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "\u092D\u093E\u0930\u0924", "Asia/Calcutta" },
{ "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "\u092D\u093E\u0930\u0924", "Asia/Calcutta" },
{ "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "IST", "Asia/Calcutta" },
{ "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "\u092D\u093E\u0930\u0924\u0940\u092F \u0938\u092E\u092F", "Asia/Calcutta" },
// ==========
@ -1276,8 +1290,8 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
{ "as", "Asia/Calcutta", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
{ "as", "Asia/Calcutta", "2004-07-15T00:00:00Z", "z", "\u09AD\u09BE. \u09B8.", "+05:30" },
{ "as", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "\u09AD\u09BE\u09F0\u09A4\u09C0\u09AF\u09BC \u09B8\u09AE\u09AF\u09BC", "+5:30" },
{ "as", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "\u09AD\u09BE\u09F0\u09A4", "Asia/Calcutta" },
{ "as", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "\u09AD\u09BE\u09F0\u09A4", "Asia/Calcutta" },
{ "as", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "\u09AD\u09BE. \u09B8.", "Asia/Calcutta" },
{ "as", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "\u09AD\u09BE\u09F0\u09A4\u09C0\u09AF\u09BC \u09B8\u09AE\u09AF\u09BC", "Asia/Calcutta" },
};

View file

@ -1057,7 +1057,9 @@ public class TimeZoneRegression extends TestFmwk {
String[] tzids = TimeZone.getAvailableIDs();
for (int i = 0; i < tzids.length; i++) {
TimeZone tz = TimeZone.getTimeZone(tzids[i]);
// Increse offset for 30 minutes
boolean useDst = tz.useDaylightTime();
// Increase offset for 30 minutes
int newRawOffset = tz.getRawOffset() + 30*60*1000;
try {
tz.setRawOffset(newRawOffset);
@ -1068,6 +1070,16 @@ public class TimeZoneRegression extends TestFmwk {
if (offset != newRawOffset) {
errln("FAIL: Modified zone(" + tz.getID() + ") - getRawOffset returns " + offset + "/ Expected: " + newRawOffset);
}
// Ticket#5917
// Check if DST observation status is not unexpectedly changed to true.
// When original Olson time zone observes DST, setRawOffset may change DST observation
// status for some zones. For example, Asia/Jerusalem, which currently use no DST after
// 2037 in tzdata 2007g. But, the opposite change (false -> true) should never happen.
if (!useDst) {
if (tz.useDaylightTime()) {
errln("FAIL: Modified zone(" + tz.getID() + ") - useDaylightTime has changed from false to true.");
}
}
// Make sure the offset is preserved in a clone
TimeZone tzClone = (TimeZone)tz.clone();
offset = tzClone.getRawOffset();

View file

@ -430,8 +430,7 @@ public class TimeZoneTest extends TestFmwk
public void TestDisplayName2() {
// Date now = new Date();
Date then = new Date(2005, 0, 1);
Date now = new Date();
String[] timezones = {"America/Chicago", "Europe/Moscow", "Europe/Rome", "Asia/Shanghai", "WET" };
String[] locales = {"en", "fr", "de", "ja", "zh_TW", "zh_Hans" };
@ -442,7 +441,7 @@ public class TimeZoneTest extends TestFmwk
String displayName0 = tz.getDisplayName(locale); // doesn't work???
SimpleDateFormat dt = new SimpleDateFormat("vvvv", locale);
dt.setTimeZone(tz);
String displayName1 = dt.format(then); // date value _does_ matter if we fallback to GMT
String displayName1 = dt.format(now); // date value _does_ matter if we fallback to GMT
logln(locale.getDisplayName() + ", " + tz.getID() + ": " + displayName0);
if (!displayName1.equals(displayName0)) {
errln(locale.getDisplayName() + ", " + tz.getID() +

View file

@ -308,8 +308,7 @@ public class OlsonTimeZone extends BasicTimeZone {
int year=it[0]; /*, month=it[1], dom=it[2], dow=it[3]*/
if (year > finalYear) { // [sic] >, not >=; see above
if (ASSERT) Assert.assrt("finalZone != null && finalZone.useDaylightTime()", finalZone != null && finalZone.useDaylightTime());
return true;
return (finalZone != null && finalZone.useDaylightTime());
}
// Find start of this year, and start of next year

View file

@ -174,7 +174,7 @@ import com.ibm.icu.util.ULocale;
* int current = wb.next();
* while (current != BreakIterator.DONE) {
* for (int p = last; p < current; p++) {
* if (Character.isLetter(text.charAt(p))
* if (Character.isLetter(text.charAt(p)))
* return last;
* }
* last = current;

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2006, International Business Machines Corporation and *
* Copyright (C) 1996-2007, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -37,11 +37,11 @@ abstract class CharsetRecog_Unicode extends CharsetRecognizer {
{
byte[] input = det.fRawInput;
if ((input[0] & 0xFF) == 0xFE && (input[1] & 0xFF) == 0xFF) {
if (input.length>=2 && ((input[0] & 0xFF) == 0xFE && (input[1] & 0xFF) == 0xFF)) {
return 100;
}
// TODO: Do some statastics to check for unsigned UTF-16BE
// TODO: Do some statistics to check for unsigned UTF-16BE
return 0;
}
}
@ -57,11 +57,17 @@ abstract class CharsetRecog_Unicode extends CharsetRecognizer {
{
byte[] input = det.fRawInput;
if ((input[0] & 0xFF) == 0xFF && (input[1] & 0xFF) == 0xFE && (input[2] != 0x00 || input[3] != 0x00)) {
return 100;
}
if (input.length >= 2 && ((input[0] & 0xFF) == 0xFF && (input[1] & 0xFF) == 0xFE))
{
// An LE BOM is present.
if (input.length>=4 && input[2] == 0x00 && input[3] == 0x00) {
// It is probably UTF-32 LE, not UTF-16
return 0;
}
return 100;
}
// TODO: Do some statastics to check for unsigned UTF-16LE
// TODO: Do some statistics to check for unsigned UTF-16LE
return 0;
}
}
@ -81,6 +87,9 @@ abstract class CharsetRecog_Unicode extends CharsetRecognizer {
boolean hasBOM = false;
int confidence = 0;
if (limit==0) {
return 0;
}
if (getChar(input, 0) == 0x0000FEFF) {
hasBOM = true;
}
@ -96,7 +105,7 @@ abstract class CharsetRecog_Unicode extends CharsetRecognizer {
}
// Cook up some sort of confidence score, based on presense of a BOM
// Cook up some sort of confidence score, based on presence of a BOM
// and the existence of valid and/or invalid multi-byte sequences.
if (hasBOM && numInvalid==0) {
confidence = 100;
@ -107,7 +116,7 @@ abstract class CharsetRecog_Unicode extends CharsetRecognizer {
} else if (numValid > 0 && numInvalid == 0) {
confidence = 80;
} else if (numValid > numInvalid*10) {
// Probably corruput UTF-32BE data. Valid sequences aren't likely by chance.
// Probably corrupt UTF-32BE data. Valid sequences aren't likely by chance.
confidence = 25;
}

View file

@ -826,26 +826,54 @@ public class SimpleDateFormat extends DateFormat {
if (zid != null) {
if (patternCharIndex == TIMEZONE_GENERIC_FIELD) {
if(count < 4){
res = formatData.getZoneString(zid, DateFormatSymbols.TIMEZONE_SHORT_GENERIC);
if ( !formatData.isCommonlyUsed(zid)) {
res = null;
}
if ( res == null ) {
mz = formatData.getMetazoneInfo(zid, DateFormatSymbols.TIMEZONE_SHORT_GENERIC,cal);
if ( mz == null || !formatData.isCommonlyUsed(mz.mzid)) {
if (cal.getTimeZone().useDaylightTime()) {
res = formatData.getZoneString(zid, DateFormatSymbols.TIMEZONE_SHORT_GENERIC);
if ( !formatData.isCommonlyUsed(zid)) {
res = null;
}
else {
res = mz.value;
}
}
if ( res == null ) {
mz = formatData.getMetazoneInfo(zid, DateFormatSymbols.TIMEZONE_SHORT_GENERIC,cal);
if ( mz == null || !formatData.isCommonlyUsed(mz.mzid)) {
res = null;
}
else {
res = mz.value;
}
}
}
else {
res = formatData.getZoneString(zid, DateFormatSymbols.TIMEZONE_SHORT_STANDARD);
if ( !formatData.isCommonlyUsed(zid)) {
res = null;
}
if ( res == null ) {
mz = formatData.getMetazoneInfo(zid, DateFormatSymbols.TIMEZONE_SHORT_STANDARD,cal);
if ( mz == null || !formatData.isCommonlyUsed(mz.mzid)) {
res = null;
}
else {
res = mz.value;
}
}
}
}else{
res = formatData.getZoneString(zid, DateFormatSymbols.TIMEZONE_LONG_GENERIC);
if ( res == null ) {
mz = formatData.getMetazoneInfo(zid, DateFormatSymbols.TIMEZONE_LONG_GENERIC,cal);
if ( mz != null ) {
res = mz.value;
}
if (cal.getTimeZone().useDaylightTime()) {
res = formatData.getZoneString(zid, DateFormatSymbols.TIMEZONE_LONG_GENERIC);
if ( res == null ) {
mz = formatData.getMetazoneInfo(zid, DateFormatSymbols.TIMEZONE_LONG_GENERIC,cal);
if ( mz != null ) {
res = mz.value;
}
}
}
else {
res = formatData.getZoneString(zid, DateFormatSymbols.TIMEZONE_LONG_STANDARD);
if ( res == null ) {
mz = formatData.getMetazoneInfo(zid, DateFormatSymbols.TIMEZONE_LONG_STANDARD,cal);
if ( mz != null ) {
res = mz.value;
}
}
}
}
} else if (patternCharIndex == TIMEZONE_SPECIAL_FIELD) {

View file

@ -71,6 +71,11 @@ class CECalendar extends Calendar {
// the Julian and Coptic or Ethiopic epoch.
// This value is set in the class initialization phase of the two
// subclasses, CopticCalendar and EthiopicCalendar
/**
* The difference between the Julian and Coptic epoch.
* @internal
* @deprecated This API is ICU internal only.
*/
protected int jdEpochOffset = -1;

View file

@ -26,93 +26,93 @@ public final class CopticCalendar extends CECalendar
private static final long serialVersionUID = 5903818751846742911L;
/**
* Constant for \u03c9\u03bf\u03b3\u03c4/\u062a\ufeee\ufe97,
* Constant for &#x03c9;&#x03bf;&#x03b3;&#x03c4;/&#x062a;&#xfeee;&#xfe97;,
* the 1st month of the Coptic year.
* @stable ICU 3.8
*/
public static final int TOUT = 0;
/**
* Constant for \u03a0\u03b1\u03bf\u03c0\u03b9/\ufeea\ufe91\ufe8e\ufe91,
* Constant for &#x03a0;&#x03b1;&#x03bf;&#x03c0;&#x03b9;/&#xfeea;&#xfe91;&#xfe8e;&#xfe91;,
* the 2nd month of the Coptic year.
* @stable ICU 3.8
*/
public static final int BABA = 1;
/**
* Constant for \u0391\u03b8\u03bf\u03c1/\u0631\ufeee\ufe97\ufe8e\ufeeb,
* Constant for &#x0391;&#x03b8;&#x03bf;&#x03c1;/&#x0631;&#xfeee;&#xfe97;&#xfe8e;&#xfeeb;,
* the 3rd month of the Coptic year.
* @stable ICU 3.8
*/
public static final int HATOR = 2;
/**
* Constant for \u03a7\u03bf\u03b9\u03b1\u03ba/\ufeda\ufeec\ufef4\ufedb,
* Constant for &#x03a7;&#x03bf;&#x03b9;&#x03b1;&#x03ba;/&#xfeda;&#xfeec;&#xfef4;&#xfedb;,
* the 4th month of the Coptic year.
* @stable ICU 3.8
*/
public static final int KIAHK = 3;
/**
* Constant for \u03a4\u03c9\u03b2\u03b9/\u0637\ufeee\ufe92\ufeeb,
* Constant for &#x03a4;&#x03c9;&#x03b2;&#x03b9;/&#x0637;&#xfeee;&#xfe92;&#xfeeb;,
* the 5th month of the Coptic year.
* @stable ICU 3.8
*/
public static final int TOBA = 4;
/**
* Constant for \u039c\u03b5\u03e3\u03b9\u03c1/\ufeae\ufef4\ufeb8\ufee3\u0623,
* Constant for &#x039c;&#x03b5;&#x03e3;&#x03b9;&#x03c1;/&#xfeae;&#xfef4;&#xfeb8;&#xfee3;&#x0623;,
* the 6th month of the Coptic year.
* @stable ICU 3.8
*/
public static final int AMSHIR = 5;
/**
* Constant for \u03a0\u03b1\u03c1\u03b5\u03bc\u03e9\u03b1\u03c4/\u062a\ufe8e\ufeec\ufee3\ufeae\ufe91,
* Constant for &#x03a0;&#x03b1;&#x03c1;&#x03b5;&#x03bc;&#x03e9;&#x03b1;&#x03c4;/&#x062a;&#xfe8e;&#xfeec;&#xfee3;&#xfeae;&#xfe91;,
* the 7th month of the Coptic year.
* @stable ICU 3.8
*/
public static final int BARAMHAT = 6;
/**
* Constant for \u03a6\u03b1\u03c1\u03bc\u03bf\u03b8\u03b9/\u0647\u062f\ufeee\ufee3\ufeae\ufe91,
* Constant for &#x03a6;&#x03b1;&#x03c1;&#x03bc;&#x03bf;&#x03b8;&#x03b9;/&#x0647;&#x062f;&#xfeee;&#xfee3;&#xfeae;&#xfe91;,
* the 8th month of the Coptic year.
* @stable ICU 3.8
*/
public static final int BARAMOUDA = 7;
/**
* Constant for \u03a0\u03b1\u03e3\u03b1\u03bd/\ufeb2\ufee8\ufeb8\ufe91,
* Constant for &#x03a0;&#x03b1;&#x03e3;&#x03b1;&#x03bd;/&#xfeb2;&#xfee8;&#xfeb8;&#xfe91;,
* the 9th month of the Coptic year.
* @stable ICU 3.8
*/
public static final int BASHANS = 8;
/**
* Constant for \u03a0\u03b1\u03c9\u03bd\u03b9/\ufeea\ufee7\u0624\ufeee\ufe91,
* Constant for &#x03a0;&#x03b1;&#x03c9;&#x03bd;&#x03b9;/&#xfeea;&#xfee7;&#x0624;&#xfeee;&#xfe91;,
* the 10th month of the Coptic year.
* @stable ICU 3.8
*/
public static final int PAONA = 9;
/**
* Constant for \u0395\u03c0\u03b7\u03c0/\ufe90\ufef4\ufe91\u0623,
* Constant for &#x0395;&#x03c0;&#x03b7;&#x03c0;/&#xfe90;&#xfef4;&#xfe91;&#x0623;,
* the 11th month of the Coptic year.
* @stable ICU 3.8
*/
public static final int EPEP = 10;
/**
* Constant for \u039c\u03b5\u03f2\u03c9\u03c1\u03b7/\u0649\ufeae\ufeb4\ufee3,
* Constant for &#x039c;&#x03b5;&#x03f2;&#x03c9;&#x03c1;&#x03b7;/&#x0649;&#xfeae;&#xfeb4;&#xfee3;,
* the 12th month of the Coptic year.
* @stable ICU 3.8
*/
public static final int MESRA = 11;
/**
* Constant for \u03a0\u03b9\u03ba\u03bf\u03b3\u03eb\u03b9
* \u03bc\u03b1\u03b2\u03bf\u03c4/\ufeae\ufef4\ufed0\ufebc\ufedf\u0627
* \ufeae\ufeec\ufeb8\ufedf\u0627,
* Constant for &#x03a0;&#x03b9;&#x03ba;&#x03bf;&#x03b3;&#x03eb;&#x03b9;
* &#x03bc;&#x03b1;&#x03b2;&#x03bf;&#x03c4;/&#xfeae;&#xfef4;&#xfed0;&#xfebc;&#xfedf;&#x0627;
* &#xfeae;&#xfeec;&#xfeb8;&#xfedf;&#x0627;,
* the 13th month of the Coptic year.
* @stable ICU 3.8
*/

View file

@ -26,79 +26,79 @@ public final class EthiopicCalendar extends CECalendar
private static final long serialVersionUID = -2438495771339315608L;
/**
* Constant for \u1218\u1235\u12a8\u1228\u121d, the 1st month of the Ethiopic year.
* Constant for &#x1218;&#x1235;&#x12a8;&#x1228;&#x121d;, the 1st month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int MESKEREM = 0;
/**
* Constant for \u1325\u1245\u121d\u1275, the 2nd month of the Ethiopic year.
* Constant for &#x1325;&#x1245;&#x121d;&#x1275;, the 2nd month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int TEKEMT = 1;
/**
* Constant for \u1285\u12f3\u122d, the 3rd month of the Ethiopic year.
* Constant for &#x1285;&#x12f3;&#x122d;, the 3rd month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int HEDAR = 2;
/**
* Constant for \u1273\u1285\u1223\u1225, the 4th month of the Ethiopic year.
* Constant for &#x1273;&#x1285;&#x1223;&#x1225;, the 4th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int TAHSAS = 3;
/**
* Constant for \u1325\u122d, the 5th month of the Ethiopic year.
* Constant for &#x1325;&#x122d;, the 5th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int TER = 4;
/**
* Constant for \u12e8\u12ab\u1272\u1275, the 6th month of the Ethiopic year.
* Constant for &#x12e8;&#x12ab;&#x1272;&#x1275;, the 6th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int YEKATIT = 5;
/**
* Constant for \u1218\u130b\u1262\u1275, the 7th month of the Ethiopic year.
* Constant for &#x1218;&#x130b;&#x1262;&#x1275;, the 7th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int MEGABIT = 6;
/**
* Constant for \u121a\u12eb\u12dd\u12eb, the 8th month of the Ethiopic year.
* Constant for &#x121a;&#x12eb;&#x12dd;&#x12eb;, the 8th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int MIAZIA = 7;
/**
* Constant for \u130d\u1295\u1266\u1275, the 9th month of the Ethiopic year.
* Constant for &#x130d;&#x1295;&#x1266;&#x1275;, the 9th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int GENBOT = 8;
/**
* Constant for \u1230\u1294, the 10th month of the Ethiopic year.
* Constant for &#x1230;&#x1294;, the 10th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int SENE = 9;
/**
* Constant for \u1210\u121d\u120c, the 11th month of the Ethiopic year.
* Constant for &#x1210;&#x121d;&#x120c;, the 11th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int HAMLE = 10;
/**
* Constant for \u1290\u1210\u1234, the 12th month of the Ethiopic year.
* Constant for &#x1290;&#x1210;&#x1234;, the 12th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int NEHASSE = 11;
/**
* Constant for \u1333\u1309\u121c\u1295, the 13th month of the Ethiopic year.
* Constant for &#x1333;&#x1309;&#x121c;&#x1295;, the 13th month of the Ethiopic year.
* @stable ICU 3.8
*/
public static final int PAGUMEN = 12;

View file

@ -769,14 +769,25 @@ public class SimpleTimeZone extends BasicTimeZone {
++month;
}
}
/*
* For some reasons, Sun Java 6 on Solaris/Linux has a problem with
* the while loop below (at least Java 6 up to build 1.6.0_02-b08).
* It looks the JRE messes up the variable 'millis' while executing
* the code in the while block. The problem is not reproduced with
* JVM option -Xint, that is, it is likely a bug of the HotSpot
* adaptive compiler. Moving 'millis += Grego.MILLIS_PER_DAY'
* to the end of this while block seems to resolve the problem.
* See ticket#5887 about the problem in detail.
*/
while (millis < 0) {
millis += Grego.MILLIS_PER_DAY;
//millis += Grego.MILLIS_PER_DAY;
--dayOfMonth;
dayOfWeek = 1 + ((dayOfWeek+5) % 7); // dayOfWeek is one-based
if (dayOfMonth < 1) {
dayOfMonth = prevMonthLen;
--month;
}
millis += Grego.MILLIS_PER_DAY;
}
if (month < ruleMonth) return -1;

View file

@ -491,26 +491,34 @@ abstract public class TimeZone implements Serializable, Cloneable {
format = new SimpleDateFormat(null, locale);
cachedLocaleData.put(locale, new SoftReference(format));
}
// Create a new SimpleTimeZone as a stand-in for this zone; the stand-in
// will have no DST, or DST during January, but the same ID and offset,
// and hence the same display name. We don't cache these because
// they're small and cheap to create.
SimpleTimeZone tz;
if (daylight && useDaylightTime()) {
int savings = getDSTSavings();
tz = new SimpleTimeZone(getRawOffset(), getID(),
Calendar.JANUARY, 1, 0, 0,
Calendar.FEBRUARY, 1, 0, 0,
savings);
} else {
tz = new SimpleTimeZone(getRawOffset(), getID());
}
String[] patterns = { "z", "zzzz", "v", "vvvv" };
format.applyPattern(patterns[style]);
format.setTimeZone(tz);
// Format a date in January. We use the value 10*ONE_DAY == Jan 11 1970
// 0:00 GMT.
return format.format(new Date(864000000L));
if ( style >= 2 ) {
// Generic names may change time to time even for a single time zone.
// This method returns the one used for the zone now.
format.setTimeZone(this);
return format.format(new Date());
} else {
// Create a new SimpleTimeZone as a stand-in for this zone; the stand-in
// will have no DST, or DST during January, but the same ID and offset,
// and hence the same display name. We don't cache these because
// they're small and cheap to create.
SimpleTimeZone tz;
if (daylight && useDaylightTime()) {
int savings = getDSTSavings();
tz = new SimpleTimeZone(getRawOffset(), getID(),
Calendar.JANUARY, 1, 0, 0,
Calendar.FEBRUARY, 1, 0, 0,
savings);
} else {
tz = new SimpleTimeZone(getRawOffset(), getID());
}
format.setTimeZone(tz);
// Format a date in January. We use the value 10*ONE_DAY == Jan 11 1970
// 0:00 GMT.
return format.format(new Date(864000000L));
}
}
/**