ICU-4162 Update data from CLDR

X-SVN-Rev: 16635
This commit is contained in:
Ram Viswanadha 2004-10-26 23:34:26 +00:00
parent 8d38207aa7
commit 6ad84fbb26
34 changed files with 860 additions and 756 deletions

View File

@ -94,7 +94,7 @@
<property name="zip.file" value="../icu4j${DSTAMP}.zip"/>
<property name="zipSrc.file" value="../icu4jSrc${DSTAMP}.zip"/>
<!-- fix the data folder every time there is a version update-->
<property name="icu4j.data.path" value="com/ibm/icu/impl/data/icudt30b/" />
<property name="icu4j.data.path" value="com/ibm/icu/impl/data/icudt32b/" />
<property name="icu4j.testdata.path" value="com/ibm/icu/dev/data/testdata/" />
<path id="build.classpath">

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:da9a53b868c8a710bbf0165c82f3b0b2f82e70f2410000e8bfbe0c64e02fd025
size 641615
oid sha256:1dbd475fa01f994a9c250415ad3c27d3c30501491b5b99307067f6364258b1a6
size 660235

View File

@ -553,7 +553,7 @@ public class TestFmwk extends AbstractTestLog {
}
}
catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("encountered exception, exiting");
}

View File

@ -26,250 +26,281 @@ public class AstroTest extends TestFmwk {
static final double PI = Math.PI;
static GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0, "UTC"));
static CalendarAstronomer astro = new CalendarAstronomer();
public void TestSolarLongitude() {
final double tests[][] = {
{ 1980, 7, 27, 00, 00, 124.114347 },
{ 1988, 7, 27, 00, 00, 124.187732 },
};
logln("");
for (int i = 0; i < tests.length; i++) {
gc.clear();
gc.set((int)tests[i][0], (int)tests[i][1]-1, (int)tests[i][2], (int)tests[i][3], (int) tests[i][4]);
astro.setDate(gc.getTime());
double longitude = astro.getSunLongitude();
longitude = 0;
Equatorial result = astro.getSunPosition();
result = null;
try{
GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0, "UTC"));
CalendarAstronomer astro = new CalendarAstronomer();
final double tests[][] = {
{ 1980, 7, 27, 00, 00, 124.114347 },
{ 1988, 7, 27, 00, 00, 124.187732 },
};
logln("");
for (int i = 0; i < tests.length; i++) {
gc.clear();
gc.set((int)tests[i][0], (int)tests[i][1]-1, (int)tests[i][2], (int)tests[i][3], (int) tests[i][4]);
astro.setDate(gc.getTime());
double longitude = astro.getSunLongitude();
longitude = 0;
Equatorial result = astro.getSunPosition();
result = null;
}
}catch(Exception ex){
warnln("Could not load data. " +ex.getMessage());
}
}
public void TestLunarPosition() {
final double tests[][] = {
{ 1979, 2, 26, 16, 00, 0, 0 },
};
logln("");
for (int i = 0; i < tests.length; i++) {
gc.clear();
gc.set((int)tests[i][0], (int)tests[i][1]-1, (int)tests[i][2], (int)tests[i][3], (int) tests[i][4]);
astro.setDate(gc.getTime());
try{
GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0, "UTC"));
CalendarAstronomer astro = new CalendarAstronomer();
final double tests[][] = {
{ 1979, 2, 26, 16, 00, 0, 0 },
};
logln("");
Equatorial result = astro.getMoonPosition();
result = null;
for (int i = 0; i < tests.length; i++) {
gc.clear();
gc.set((int)tests[i][0], (int)tests[i][1]-1, (int)tests[i][2], (int)tests[i][3], (int) tests[i][4]);
astro.setDate(gc.getTime());
Equatorial result = astro.getMoonPosition();
result = null;
}
}catch(Exception ex){
warnln("Could not load data. "+ex.getMessage());
}
}
public void TestCoordinates() {
Equatorial result = astro.eclipticToEquatorial(139.686111 * PI/ 180.0, 4.875278* PI / 180.0);
logln("result is " + result + "; " + result.toHmsString());
try{
GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0, "UTC"));
CalendarAstronomer astro = new CalendarAstronomer();
Equatorial result = astro.eclipticToEquatorial(139.686111 * PI/ 180.0, 4.875278* PI / 180.0);
logln("result is " + result + "; " + result.toHmsString());
}catch(Exception ex){
warnln("Could not load data. " + ex.getMessage());
}
}
public void TestCoverage() {
GregorianCalendar cal = new GregorianCalendar(1958, Calendar.AUGUST, 15);
Date then = cal.getTime();
CalendarAstronomer myastro = new CalendarAstronomer(then);
//Latitude: 34 degrees 05' North
//Longitude: 118 degrees 22' West
double laLat = 34 + 5d/60, laLong = 360 - (118 + 22d/60);
CalendarAstronomer myastro2 = new CalendarAstronomer(laLong, laLat);
double eclLat = laLat * Math.PI / 360;
double eclLong = laLong * Math.PI / 360;
Ecliptic ecl = new Ecliptic(eclLat, eclLong);
logln("ecliptic: " + ecl);
CalendarAstronomer myastro3 = new CalendarAstronomer();
myastro3.setJulianDay((4713 + 2000) * 365.25);
CalendarAstronomer[] astronomers = {
myastro, myastro2, myastro3, myastro2 // check cache
};
for (int i = 0; i < astronomers.length; ++i) {
CalendarAstronomer astro = astronomers[i];
logln("astro: " + astro);
logln(" time: " + astro.getTime());
logln(" date: " + astro.getDate());
logln(" cent: " + astro.getJulianCentury());
logln(" gw sidereal: " + astro.getGreenwichSidereal());
logln(" loc sidereal: " + astro.getLocalSidereal());
logln(" equ ecl: " + astro.eclipticToEquatorial(ecl));
logln(" equ long: " + astro.eclipticToEquatorial(eclLong));
logln(" horiz: " + astro.eclipticToHorizon(eclLong));
logln(" sunrise: " + new Date(astro.getSunRiseSet(true)));
logln(" sunset: " + new Date(astro.getSunRiseSet(false)));
logln(" moon phase: " + astro.getMoonPhase());
logln(" moonrise: " + new Date(astro.getMoonRiseSet(true)));
logln(" moonset: " + new Date(astro.getMoonRiseSet(false)));
logln(" prev summer solstice: " + new Date(astro.getSunTime(CalendarAstronomer.SUMMER_SOLSTICE, false)));
logln(" next summer solstice: " + new Date(astro.getSunTime(CalendarAstronomer.SUMMER_SOLSTICE, true)));
logln(" prev full moon: " + new Date(astro.getMoonTime(CalendarAstronomer.FULL_MOON, false)));
logln(" next full moon: " + new Date(astro.getMoonTime(CalendarAstronomer.FULL_MOON, true)));
}
try{
GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0, "UTC"));
GregorianCalendar cal = new GregorianCalendar(1958, Calendar.AUGUST, 15);
Date then = cal.getTime();
CalendarAstronomer myastro = new CalendarAstronomer(then);
//Latitude: 34 degrees 05' North
//Longitude: 118 degrees 22' West
double laLat = 34 + 5d/60, laLong = 360 - (118 + 22d/60);
CalendarAstronomer myastro2 = new CalendarAstronomer(laLong, laLat);
double eclLat = laLat * Math.PI / 360;
double eclLong = laLong * Math.PI / 360;
Ecliptic ecl = new Ecliptic(eclLat, eclLong);
logln("ecliptic: " + ecl);
CalendarAstronomer myastro3 = new CalendarAstronomer();
myastro3.setJulianDay((4713 + 2000) * 365.25);
CalendarAstronomer[] astronomers = {
myastro, myastro2, myastro3, myastro2 // check cache
};
for (int i = 0; i < astronomers.length; ++i) {
CalendarAstronomer astro = astronomers[i];
logln("astro: " + astro);
logln(" time: " + astro.getTime());
logln(" date: " + astro.getDate());
logln(" cent: " + astro.getJulianCentury());
logln(" gw sidereal: " + astro.getGreenwichSidereal());
logln(" loc sidereal: " + astro.getLocalSidereal());
logln(" equ ecl: " + astro.eclipticToEquatorial(ecl));
logln(" equ long: " + astro.eclipticToEquatorial(eclLong));
logln(" horiz: " + astro.eclipticToHorizon(eclLong));
logln(" sunrise: " + new Date(astro.getSunRiseSet(true)));
logln(" sunset: " + new Date(astro.getSunRiseSet(false)));
logln(" moon phase: " + astro.getMoonPhase());
logln(" moonrise: " + new Date(astro.getMoonRiseSet(true)));
logln(" moonset: " + new Date(astro.getMoonRiseSet(false)));
logln(" prev summer solstice: " + new Date(astro.getSunTime(CalendarAstronomer.SUMMER_SOLSTICE, false)));
logln(" next summer solstice: " + new Date(astro.getSunTime(CalendarAstronomer.SUMMER_SOLSTICE, true)));
logln(" prev full moon: " + new Date(astro.getMoonTime(CalendarAstronomer.FULL_MOON, false)));
logln(" next full moon: " + new Date(astro.getMoonTime(CalendarAstronomer.FULL_MOON, true)));
}
}catch(Exception ex){
warnln("Could not load data. "+ ex.getMessage());
}
}
static final long DAY_MS = 24*60*60*1000L;
public void TestSunriseTimes() {
// logln("Sunrise/Sunset times for San Jose, California, USA");
// CalendarAstronomer astro = new CalendarAstronomer(-121.55, 37.20);
// TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
// We'll use a table generated by the UNSO website as our reference
// From: http://aa.usno.navy.mil/
//-Location: W079 25, N43 40
//-Rise and Set for the Sun for 2001
//-Zone: 4h West of Greenwich
int[] USNO = {
6,59, 19,45,
6,57, 19,46,
6,56, 19,47,
6,54, 19,48,
6,52, 19,49,
6,50, 19,51,
6,48, 19,52,
6,47, 19,53,
6,45, 19,54,
6,43, 19,55,
6,42, 19,57,
6,40, 19,58,
6,38, 19,59,
6,36, 20, 0,
6,35, 20, 1,
6,33, 20, 3,
6,31, 20, 4,
6,30, 20, 5,
6,28, 20, 6,
6,27, 20, 7,
6,25, 20, 8,
6,23, 20,10,
6,22, 20,11,
6,20, 20,12,
6,19, 20,13,
6,17, 20,14,
6,16, 20,16,
6,14, 20,17,
6,13, 20,18,
6,11, 20,19,
};
logln("Sunrise/Sunset times for Toronto, Canada");
CalendarAstronomer astro = new CalendarAstronomer(-(79+25/60), 43+40/60);
// As of ICU4J 2.8 the ICU4J time zones implement pass-through
// to the underlying JDK. Because of variation in the
// underlying JDKs, we have to use a fixed-offset
// SimpleTimeZone to get consistent behavior between JDKs.
// The offset we want is [-18000000, 3600000] (raw, dst).
// [aliu 10/15/03]
// TimeZone tz = TimeZone.getTimeZone("America/Montreal");
TimeZone tz = new SimpleTimeZone(-18000000 + 3600000, "Montreal(FIXED)");
GregorianCalendar cal = new GregorianCalendar(tz, Locale.US);
GregorianCalendar cal2 = new GregorianCalendar(tz, Locale.US);
cal.clear();
cal.set(Calendar.YEAR, 2001);
cal.set(Calendar.MONTH, Calendar.APRIL);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 12); // must be near local noon for getSunRiseSet to work
DateFormat df = DateFormat.getTimeInstance(cal, DateFormat.MEDIUM, Locale.US);
DateFormat df2 = DateFormat.getDateTimeInstance(cal, DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US);
DateFormat day = DateFormat.getDateInstance(cal, DateFormat.MEDIUM, Locale.US);
for (int i=0; i < 30; i++) {
astro.setDate(cal.getTime());
Date sunrise = new Date(astro.getSunRiseSet(true));
Date sunset = new Date(astro.getSunRiseSet(false));
cal2.setTime(cal.getTime());
cal2.set(Calendar.SECOND, 0);
cal2.set(Calendar.MILLISECOND, 0);
cal2.set(Calendar.HOUR_OF_DAY, USNO[4*i+0]);
cal2.set(Calendar.MINUTE, USNO[4*i+1]);
Date exprise = cal2.getTime();
cal2.set(Calendar.HOUR_OF_DAY, USNO[4*i+2]);
cal2.set(Calendar.MINUTE, USNO[4*i+3]);
Date expset = cal2.getTime();
// Compute delta of what we got to the USNO data, in seconds
int deltarise = Math.abs((int)(sunrise.getTime() - exprise.getTime()) / 1000);
int deltaset = Math.abs((int)(sunset.getTime() - expset.getTime()) / 1000);
// Allow a deviation of 0..MAX_DEV seconds
// It would be nice to get down to 60 seconds, but at this
// point that appears to be impossible without a redo of the
// algorithm using something more advanced than Duffett-Smith.
final int MAX_DEV = 180;
if (deltarise > MAX_DEV || deltaset > MAX_DEV) {
if (deltarise > MAX_DEV) {
errln("FAIL: " + day.format(cal.getTime()) +
", Sunrise: " + df2.format(sunrise) +
" (USNO " + df.format(exprise) +
" d=" + deltarise + "s)");
try{
// logln("Sunrise/Sunset times for San Jose, California, USA");
// CalendarAstronomer astro = new CalendarAstronomer(-121.55, 37.20);
// TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
// We'll use a table generated by the UNSO website as our reference
// From: http://aa.usno.navy.mil/
//-Location: W079 25, N43 40
//-Rise and Set for the Sun for 2001
//-Zone: 4h West of Greenwich
int[] USNO = {
6,59, 19,45,
6,57, 19,46,
6,56, 19,47,
6,54, 19,48,
6,52, 19,49,
6,50, 19,51,
6,48, 19,52,
6,47, 19,53,
6,45, 19,54,
6,43, 19,55,
6,42, 19,57,
6,40, 19,58,
6,38, 19,59,
6,36, 20, 0,
6,35, 20, 1,
6,33, 20, 3,
6,31, 20, 4,
6,30, 20, 5,
6,28, 20, 6,
6,27, 20, 7,
6,25, 20, 8,
6,23, 20,10,
6,22, 20,11,
6,20, 20,12,
6,19, 20,13,
6,17, 20,14,
6,16, 20,16,
6,14, 20,17,
6,13, 20,18,
6,11, 20,19,
};
logln("Sunrise/Sunset times for Toronto, Canada");
CalendarAstronomer astro = new CalendarAstronomer(-(79+25/60), 43+40/60);
// As of ICU4J 2.8 the ICU4J time zones implement pass-through
// to the underlying JDK. Because of variation in the
// underlying JDKs, we have to use a fixed-offset
// SimpleTimeZone to get consistent behavior between JDKs.
// The offset we want is [-18000000, 3600000] (raw, dst).
// [aliu 10/15/03]
// TimeZone tz = TimeZone.getTimeZone("America/Montreal");
TimeZone tz = new SimpleTimeZone(-18000000 + 3600000, "Montreal(FIXED)");
GregorianCalendar cal = new GregorianCalendar(tz, Locale.US);
GregorianCalendar cal2 = new GregorianCalendar(tz, Locale.US);
cal.clear();
cal.set(Calendar.YEAR, 2001);
cal.set(Calendar.MONTH, Calendar.APRIL);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 12); // must be near local noon for getSunRiseSet to work
DateFormat df = DateFormat.getTimeInstance(cal, DateFormat.MEDIUM, Locale.US);
DateFormat df2 = DateFormat.getDateTimeInstance(cal, DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US);
DateFormat day = DateFormat.getDateInstance(cal, DateFormat.MEDIUM, Locale.US);
for (int i=0; i < 30; i++) {
astro.setDate(cal.getTime());
Date sunrise = new Date(astro.getSunRiseSet(true));
Date sunset = new Date(astro.getSunRiseSet(false));
cal2.setTime(cal.getTime());
cal2.set(Calendar.SECOND, 0);
cal2.set(Calendar.MILLISECOND, 0);
cal2.set(Calendar.HOUR_OF_DAY, USNO[4*i+0]);
cal2.set(Calendar.MINUTE, USNO[4*i+1]);
Date exprise = cal2.getTime();
cal2.set(Calendar.HOUR_OF_DAY, USNO[4*i+2]);
cal2.set(Calendar.MINUTE, USNO[4*i+3]);
Date expset = cal2.getTime();
// Compute delta of what we got to the USNO data, in seconds
int deltarise = Math.abs((int)(sunrise.getTime() - exprise.getTime()) / 1000);
int deltaset = Math.abs((int)(sunset.getTime() - expset.getTime()) / 1000);
// Allow a deviation of 0..MAX_DEV seconds
// It would be nice to get down to 60 seconds, but at this
// point that appears to be impossible without a redo of the
// algorithm using something more advanced than Duffett-Smith.
final int MAX_DEV = 180;
if (deltarise > MAX_DEV || deltaset > MAX_DEV) {
if (deltarise > MAX_DEV) {
errln("FAIL: " + day.format(cal.getTime()) +
", Sunrise: " + df2.format(sunrise) +
" (USNO " + df.format(exprise) +
" d=" + deltarise + "s)");
} else {
logln(day.format(cal.getTime()) +
", Sunrise: " + df.format(sunrise) +
" (USNO " + df.format(exprise) + ")");
}
if (deltaset > MAX_DEV) {
errln("FAIL: " + day.format(cal.getTime()) +
", Sunset: " + df2.format(sunset) +
" (USNO " + df.format(expset) +
" d=" + deltaset + "s)");
} else {
logln(day.format(cal.getTime()) +
", Sunset: " + df.format(sunset) +
" (USNO " + df.format(expset) + ")");
}
} else {
logln(day.format(cal.getTime()) +
", Sunrise: " + df.format(sunrise) +
" (USNO " + df.format(exprise) + ")");
}
if (deltaset > MAX_DEV) {
errln("FAIL: " + day.format(cal.getTime()) +
", Sunset: " + df2.format(sunset) +
" (USNO " + df.format(expset) +
" d=" + deltaset + "s)");
} else {
logln(day.format(cal.getTime()) +
" (USNO " + df.format(exprise) + ")" +
", Sunset: " + df.format(sunset) +
" (USNO " + df.format(expset) + ")");
}
} else {
logln(day.format(cal.getTime()) +
", Sunrise: " + df.format(sunrise) +
" (USNO " + df.format(exprise) + ")" +
", Sunset: " + df.format(sunset) +
" (USNO " + df.format(expset) + ")");
}
cal.add(Calendar.DATE, 1);
}
// CalendarAstronomer a = new CalendarAstronomer(-(71+5/60), 42+37/60);
// cal.clear();
// cal.set(cal.YEAR, 1986);
// cal.set(cal.MONTH, cal.MARCH);
// cal.set(cal.DATE, 10);
// cal.set(cal.YEAR, 1988);
// cal.set(cal.MONTH, cal.JULY);
// cal.set(cal.DATE, 27);
// a.setDate(cal.getTime());
// long r = a.getSunRiseSet2(true);
cal.add(Calendar.DATE, 1);
}
// CalendarAstronomer a = new CalendarAstronomer(-(71+5/60), 42+37/60);
// cal.clear();
// cal.set(cal.YEAR, 1986);
// cal.set(cal.MONTH, cal.MARCH);
// cal.set(cal.DATE, 10);
// cal.set(cal.YEAR, 1988);
// cal.set(cal.MONTH, cal.JULY);
// cal.set(cal.DATE, 27);
// a.setDate(cal.getTime());
// long r = a.getSunRiseSet2(true);
}catch(Exception ex){
warnln("Could not load data. " + ex.getMessage());
}
}
public void TestBasics() {
// Check that our JD computation is the same as the book's (p. 88)
GregorianCalendar cal3 = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.US);
DateFormat d3 = DateFormat.getDateTimeInstance(cal3, DateFormat.MEDIUM,DateFormat.MEDIUM,Locale.US);
cal3.clear();
cal3.set(Calendar.YEAR, 1980);
cal3.set(Calendar.MONTH, Calendar.JULY);
cal3.set(Calendar.DATE, 27);
astro.setDate(cal3.getTime());
double jd = astro.getJulianDay() - 2447891.5;
double exp = -3444;
if (jd == exp) {
logln(d3.format(cal3.getTime()) + " => " + jd);
} else {
errln("FAIL: " + d3.format(cal3.getTime()) + " => " + jd +
", expected " + exp);
try{
GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0, "UTC"));
CalendarAstronomer astro = new CalendarAstronomer();
GregorianCalendar cal3 = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.US);
DateFormat d3 = DateFormat.getDateTimeInstance(cal3, DateFormat.MEDIUM,DateFormat.MEDIUM,Locale.US);
cal3.clear();
cal3.set(Calendar.YEAR, 1980);
cal3.set(Calendar.MONTH, Calendar.JULY);
cal3.set(Calendar.DATE, 27);
astro.setDate(cal3.getTime());
double jd = astro.getJulianDay() - 2447891.5;
double exp = -3444;
if (jd == exp) {
logln(d3.format(cal3.getTime()) + " => " + jd);
} else {
errln("FAIL: " + d3.format(cal3.getTime()) + " => " + jd +
", expected " + exp);
}
}catch(Exception ex){
warnln("Exception: "+ ex.getMessage());
}
// cal3.clear();

View File

@ -10,6 +10,7 @@ import com.ibm.icu.util.*;
import java.util.Date;
import java.util.Locale;
import com.ibm.icu.impl.CalendarAstronomer;
import com.ibm.icu.text.*;
/**
@ -25,15 +26,15 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
public static void main(String[] args) throws Exception {
new CalendarRegression().run(args);
}
static final String[] FIELD_NAME = {
"ERA", "YEAR", "MONTH", "WEEK_OF_YEAR", "WEEK_OF_MONTH",
"DAY_OF_MONTH", "DAY_OF_YEAR", "DAY_OF_WEEK",
"DAY_OF_WEEK_IN_MONTH", "AM_PM", "HOUR", "HOUR_OF_DAY",
"MINUTE", "SECOND", "MILLISECOND", "ZONE_OFFSET",
"DST_OFFSET", "YEAR_WOY", "DOW_LOCAL", "EXTENDED_YEAR",
"JULIAN_DAY", "MILLISECONDS_IN_DAY",
};
"ERA", "YEAR", "MONTH", "WEEK_OF_YEAR", "WEEK_OF_MONTH",
"DAY_OF_MONTH", "DAY_OF_YEAR", "DAY_OF_WEEK",
"DAY_OF_WEEK_IN_MONTH", "AM_PM", "HOUR", "HOUR_OF_DAY",
"MINUTE", "SECOND", "MILLISECOND", "ZONE_OFFSET",
"DST_OFFSET", "YEAR_WOY", "DOW_LOCAL", "EXTENDED_YEAR",
"JULIAN_DAY", "MILLISECONDS_IN_DAY"
};
/*
Synopsis: java.sql.Timestamp constructor works wrong on Windows 95
@ -55,187 +56,209 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
*/
public void Test4031502() {
// This bug actually occurs on Windows NT as well, and doesn't
// require the host zone to be set; it can be set in Java.
String[] ids = TimeZone.getAvailableIDs();
boolean bad = false;
for (int i=0; i<ids.length; ++i) {
TimeZone zone = TimeZone.getTimeZone(ids[i]);
GregorianCalendar cal = new GregorianCalendar(zone);
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
if (cal.get(Calendar.HOUR) != 5) {
logln("Fail: " + zone.getID() + " " +
zone.useDaylightTime() + "; DST_OFFSET = " +
cal.get(Calendar.DST_OFFSET) / (60*60*1000.0) + "; ZONE_OFFSET = " +
cal.get(Calendar.ZONE_OFFSET) / (60*60*1000.0) + "; getRawOffset() = " +
zone.getRawOffset() / (60*60*1000.0) +
"; HOUR = " + cal.get(Calendar.HOUR));
try{
// This bug actually occurs on Windows NT as well, and doesn't
// require the host zone to be set; it can be set in Java.
String[] ids = TimeZone.getAvailableIDs();
boolean bad = false;
for (int i=0; i<ids.length; ++i) {
TimeZone zone = TimeZone.getTimeZone(ids[i]);
GregorianCalendar cal = new GregorianCalendar(zone);
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
logln("ms = " + cal.getTime() + " (" + cal.getTime().getTime() + ")");
cal.get(Calendar.HOUR);
java.util.GregorianCalendar cal2 = new java.util.GregorianCalendar(java.util.TimeZone.getTimeZone(ids[i]));
cal2.clear();
cal2.set(1900, 15, 5, 5, 8, 13);
cal2.get(Calendar.HOUR);
logln("java.util.GC: " + zone.getID() + " " +
zone.useDaylightTime() + "; DST_OFFSET = " +
cal2.get(Calendar.DST_OFFSET) / (60*60*1000.0) + "; ZONE_OFFSET = " +
cal2.get(Calendar.ZONE_OFFSET) / (60*60*1000.0) + "; getRawOffset() = " +
zone.getRawOffset() / (60*60*1000.0) +
"; HOUR = " + cal.get(Calendar.HOUR));
logln("ms = " + cal2.getTime() + " (" + cal2.getTime().getTime() + ")");
bad = true;
} else if (false) { // Change to true to debug
logln("OK: " + zone.getID() + " " +
zone.useDaylightTime() + " " +
cal.get(Calendar.DST_OFFSET) / (60*60*1000) + " " +
zone.getRawOffset() / (60*60*1000) +
": HOUR = " + cal.get(Calendar.HOUR));
if (cal.get(Calendar.HOUR) != 5) {
logln("Fail: " + zone.getID() + " " +
zone.useDaylightTime() + "; DST_OFFSET = " +
cal.get(Calendar.DST_OFFSET) / (60*60*1000.0) + "; ZONE_OFFSET = " +
cal.get(Calendar.ZONE_OFFSET) / (60*60*1000.0) + "; getRawOffset() = " +
zone.getRawOffset() / (60*60*1000.0) +
"; HOUR = " + cal.get(Calendar.HOUR));
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
if (cal.get(Calendar.HOUR) != 5) {
logln("Fail: " + zone.getID() + " " +
zone.useDaylightTime() + "; DST_OFFSET = " +
cal.get(Calendar.DST_OFFSET) / (60*60*1000.0) + "; ZONE_OFFSET = " +
cal.get(Calendar.ZONE_OFFSET) / (60*60*1000.0) + "; getRawOffset() = " +
zone.getRawOffset() / (60*60*1000.0) +
"; HOUR = " + cal.get(Calendar.HOUR));
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
logln("ms = " + cal.getTime() + " (" + cal.getTime().getTime() + ")");
cal.get(Calendar.HOUR);
java.util.GregorianCalendar cal2 = new java.util.GregorianCalendar(java.util.TimeZone.getTimeZone(ids[i]));
cal2.clear();
cal2.set(1900, 15, 5, 5, 8, 13);
cal2.get(Calendar.HOUR);
logln("java.util.GC: " + zone.getID() + " " +
zone.useDaylightTime() + "; DST_OFFSET = " +
cal2.get(Calendar.DST_OFFSET) / (60*60*1000.0) + "; ZONE_OFFSET = " +
cal2.get(Calendar.ZONE_OFFSET) / (60*60*1000.0) + "; getRawOffset() = " +
zone.getRawOffset() / (60*60*1000.0) +
"; HOUR = " + cal.get(Calendar.HOUR));
logln("ms = " + cal2.getTime() + " (" + cal2.getTime().getTime() + ")");
bad = true;
} else if (false) { // Change to true to debug
logln("OK: " + zone.getID() + " " +
zone.useDaylightTime() + " " +
cal.get(Calendar.DST_OFFSET) / (60*60*1000) + " " +
zone.getRawOffset() / (60*60*1000) +
": HOUR = " + cal.get(Calendar.HOUR));
}
}
if (bad) errln("TimeZone problems with GC");
}
} catch (Exception e) {
warnln("Could not load data. "+ e.getMessage());
}
if (bad) errln("TimeZone problems with GC");
}
public void Test4035301() {
GregorianCalendar c = new GregorianCalendar(98, 8, 7);
GregorianCalendar d = new GregorianCalendar(98, 8, 7);
if (c.after(d) ||
c.after(c) ||
c.before(d) ||
c.before(c) ||
!c.equals(c) ||
!c.equals(d))
errln("Fail");
try {
GregorianCalendar c = new GregorianCalendar(98, 8, 7);
GregorianCalendar d = new GregorianCalendar(98, 8, 7);
if (c.after(d) ||
c.after(c) ||
c.before(d) ||
c.before(c) ||
!c.equals(c) ||
!c.equals(d))
errln("Fail");
} catch (Exception e) {
// TODO Auto-generated catch block
warnln("Could not load data. "+ e.getMessage());
}
}
public void Test4040996() {
String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
Calendar calendar = new GregorianCalendar(pdt);
try {
String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
Calendar calendar = new GregorianCalendar(pdt);
calendar.set(Calendar.MONTH,3);
calendar.set(Calendar.DAY_OF_MONTH,18);
calendar.set(Calendar.SECOND, 30);
calendar.set(Calendar.MONTH,3);
calendar.set(Calendar.DAY_OF_MONTH,18);
calendar.set(Calendar.SECOND, 30);
logln("MONTH: " + calendar.get(Calendar.MONTH));
logln("DAY_OF_MONTH: " +
calendar.get(Calendar.DAY_OF_MONTH));
logln("MINUTE: " + calendar.get(Calendar.MINUTE));
logln("SECOND: " + calendar.get(Calendar.SECOND));
logln("MONTH: " + calendar.get(Calendar.MONTH));
logln("DAY_OF_MONTH: " +
calendar.get(Calendar.DAY_OF_MONTH));
logln("MINUTE: " + calendar.get(Calendar.MINUTE));
logln("SECOND: " + calendar.get(Calendar.SECOND));
calendar.add(Calendar.SECOND,6);
//This will print out todays date for MONTH and DAY_OF_MONTH
//instead of the date it was set to.
//This happens when adding MILLISECOND or MINUTE also
logln("MONTH: " + calendar.get(Calendar.MONTH));
logln("DAY_OF_MONTH: " +
calendar.get(Calendar.DAY_OF_MONTH));
logln("MINUTE: " + calendar.get(Calendar.MINUTE));
logln("SECOND: " + calendar.get(Calendar.SECOND));
if (calendar.get(Calendar.MONTH) != 3 ||
calendar.get(Calendar.DAY_OF_MONTH) != 18 ||
calendar.get(Calendar.SECOND) != 36)
errln("Fail: Calendar.add misbehaves");
calendar.add(Calendar.SECOND,6);
//This will print out todays date for MONTH and DAY_OF_MONTH
//instead of the date it was set to.
//This happens when adding MILLISECOND or MINUTE also
logln("MONTH: " + calendar.get(Calendar.MONTH));
logln("DAY_OF_MONTH: " +
calendar.get(Calendar.DAY_OF_MONTH));
logln("MINUTE: " + calendar.get(Calendar.MINUTE));
logln("SECOND: " + calendar.get(Calendar.SECOND));
if (calendar.get(Calendar.MONTH) != 3 ||
calendar.get(Calendar.DAY_OF_MONTH) != 18 ||
calendar.get(Calendar.SECOND) != 36)
errln("Fail: Calendar.add misbehaves");
} catch (Exception e) {
warnln("Could not load data. "+ e.getMessage());
}
}
public void Test4051765() {
Calendar cal = Calendar.getInstance();
cal.setLenient(false);
cal.set(Calendar.DAY_OF_WEEK, 0);
try {
cal.getTime();
errln("Fail: DAY_OF_WEEK 0 should be disallowed");
}
catch (IllegalArgumentException e) {
return;
Calendar cal = Calendar.getInstance();
cal.setLenient(false);
cal.set(Calendar.DAY_OF_WEEK, 0);
try {
cal.getTime();
errln("Fail: DAY_OF_WEEK 0 should be disallowed");
}
catch (IllegalArgumentException e) {
return;
}
} catch (Exception e) {
// TODO Auto-generated catch block
warnln("Could not load data. "+ e.getMessage());
}
}
/* User error - no bug here
public void Test4059524() {
// Create calendar for April 10, 1997
GregorianCalendar calendar = new GregorianCalendar();
// print out a bunch of interesting things
logln("ERA: " + calendar.get(calendar.ERA));
logln("YEAR: " + calendar.get(calendar.YEAR));
logln("MONTH: " + calendar.get(calendar.MONTH));
logln("WEEK_OF_YEAR: " +
calendar.get(calendar.WEEK_OF_YEAR));
logln("WEEK_OF_MONTH: " +
calendar.get(calendar.WEEK_OF_MONTH));
logln("DATE: " + calendar.get(calendar.DATE));
logln("DAY_OF_MONTH: " +
calendar.get(calendar.DAY_OF_MONTH));
logln("DAY_OF_YEAR: " + calendar.get(calendar.DAY_OF_YEAR));
logln("DAY_OF_WEEK: " + calendar.get(calendar.DAY_OF_WEEK));
logln("DAY_OF_WEEK_IN_MONTH: " +
calendar.get(calendar.DAY_OF_WEEK_IN_MONTH));
logln("AM_PM: " + calendar.get(calendar.AM_PM));
logln("HOUR: " + calendar.get(calendar.HOUR));
logln("HOUR_OF_DAY: " + calendar.get(calendar.HOUR_OF_DAY));
logln("MINUTE: " + calendar.get(calendar.MINUTE));
logln("SECOND: " + calendar.get(calendar.SECOND));
logln("MILLISECOND: " + calendar.get(calendar.MILLISECOND));
logln("ZONE_OFFSET: "
+ (calendar.get(calendar.ZONE_OFFSET)/(60*60*1000)));
logln("DST_OFFSET: "
+ (calendar.get(calendar.DST_OFFSET)/(60*60*1000)));
calendar = new GregorianCalendar(1997,3,10);
calendar.getTime();
logln("April 10, 1997");
logln("ERA: " + calendar.get(calendar.ERA));
logln("YEAR: " + calendar.get(calendar.YEAR));
logln("MONTH: " + calendar.get(calendar.MONTH));
logln("WEEK_OF_YEAR: " +
calendar.get(calendar.WEEK_OF_YEAR));
logln("WEEK_OF_MONTH: " +
calendar.get(calendar.WEEK_OF_MONTH));
logln("DATE: " + calendar.get(calendar.DATE));
logln("DAY_OF_MONTH: " +
calendar.get(calendar.DAY_OF_MONTH));
logln("DAY_OF_YEAR: " + calendar.get(calendar.DAY_OF_YEAR));
logln("DAY_OF_WEEK: " + calendar.get(calendar.DAY_OF_WEEK));
logln("DAY_OF_WEEK_IN_MONTH: " + calendar.get(calendar.DAY_OF_WEEK_IN_MONTH));
logln("AM_PM: " + calendar.get(calendar.AM_PM));
logln("HOUR: " + calendar.get(calendar.HOUR));
logln("HOUR_OF_DAY: " + calendar.get(calendar.HOUR_OF_DAY));
logln("MINUTE: " + calendar.get(calendar.MINUTE));
logln("SECOND: " + calendar.get(calendar.SECOND));
logln("MILLISECOND: " + calendar.get(calendar.MILLISECOND));
logln("ZONE_OFFSET: "
+ (calendar.get(calendar.ZONE_OFFSET)/(60*60*1000))); // in hours
logln("DST_OFFSET: "
+ (calendar.get(calendar.DST_OFFSET)/(60*60*1000))); // in hours
}
*/
/*
* User error - no bug here public void Test4059524() { // Create calendar
* for April 10, 1997 GregorianCalendar calendar = new GregorianCalendar(); //
* print out a bunch of interesting things logln("ERA: " +
* calendar.get(calendar.ERA)); logln("YEAR: " +
* calendar.get(calendar.YEAR)); logln("MONTH: " +
* calendar.get(calendar.MONTH)); logln("WEEK_OF_YEAR: " +
* calendar.get(calendar.WEEK_OF_YEAR)); logln("WEEK_OF_MONTH: " +
* calendar.get(calendar.WEEK_OF_MONTH)); logln("DATE: " +
* calendar.get(calendar.DATE)); logln("DAY_OF_MONTH: " +
* calendar.get(calendar.DAY_OF_MONTH)); logln("DAY_OF_YEAR: " +
* calendar.get(calendar.DAY_OF_YEAR)); logln("DAY_OF_WEEK: " +
* calendar.get(calendar.DAY_OF_WEEK)); logln("DAY_OF_WEEK_IN_MONTH: " +
* calendar.get(calendar.DAY_OF_WEEK_IN_MONTH)); logln("AM_PM: " +
* calendar.get(calendar.AM_PM)); logln("HOUR: " +
* calendar.get(calendar.HOUR)); logln("HOUR_OF_DAY: " +
* calendar.get(calendar.HOUR_OF_DAY)); logln("MINUTE: " +
* calendar.get(calendar.MINUTE)); logln("SECOND: " +
* calendar.get(calendar.SECOND)); logln("MILLISECOND: " +
* calendar.get(calendar.MILLISECOND)); logln("ZONE_OFFSET: " +
* (calendar.get(calendar.ZONE_OFFSET)/(60*60*1000))); logln("DST_OFFSET: " +
* (calendar.get(calendar.DST_OFFSET)/(60*60*1000))); calendar = new
* GregorianCalendar(1997,3,10); calendar.getTime(); logln("April 10,
* 1997"); logln("ERA: " + calendar.get(calendar.ERA)); logln("YEAR: " +
* calendar.get(calendar.YEAR)); logln("MONTH: " +
* calendar.get(calendar.MONTH)); logln("WEEK_OF_YEAR: " +
* calendar.get(calendar.WEEK_OF_YEAR)); logln("WEEK_OF_MONTH: " +
* calendar.get(calendar.WEEK_OF_MONTH)); logln("DATE: " +
* calendar.get(calendar.DATE)); logln("DAY_OF_MONTH: " +
* calendar.get(calendar.DAY_OF_MONTH)); logln("DAY_OF_YEAR: " +
* calendar.get(calendar.DAY_OF_YEAR)); logln("DAY_OF_WEEK: " +
* calendar.get(calendar.DAY_OF_WEEK)); logln("DAY_OF_WEEK_IN_MONTH: " +
* calendar.get(calendar.DAY_OF_WEEK_IN_MONTH)); logln("AM_PM: " +
* calendar.get(calendar.AM_PM)); logln("HOUR: " +
* calendar.get(calendar.HOUR)); logln("HOUR_OF_DAY: " +
* calendar.get(calendar.HOUR_OF_DAY)); logln("MINUTE: " +
* calendar.get(calendar.MINUTE)); logln("SECOND: " +
* calendar.get(calendar.SECOND)); logln("MILLISECOND: " +
* calendar.get(calendar.MILLISECOND)); logln("ZONE_OFFSET: " +
* (calendar.get(calendar.ZONE_OFFSET)/(60*60*1000))); // in hours
* logln("DST_OFFSET: " + (calendar.get(calendar.DST_OFFSET)/(60*60*1000))); //
* in hours }
*/
public void Test4059654() {
// work around bug for jdk1.4 on solaris 2.6, which uses funky timezone names
// jdk1.4.1 will drop support for 2.6 so we should be ok when it comes out
java.util.TimeZone javazone = java.util.TimeZone.getTimeZone("GMT");
TimeZone icuzone = TimeZone.getTimeZone("GMT");
try {
// work around bug for jdk1.4 on solaris 2.6, which uses funky
// timezone names
// jdk1.4.1 will drop support for 2.6 so we should be ok when it
// comes out
java.util.TimeZone javazone = java.util.TimeZone.getTimeZone("GMT");
TimeZone icuzone = TimeZone.getTimeZone("GMT");
GregorianCalendar gc = new GregorianCalendar(icuzone);
gc.set(1997, 3, 1, 15, 16, 17); // April 1, 1997
GregorianCalendar gc = new GregorianCalendar(icuzone);
gc.set(1997, 3, 1, 15, 16, 17); // April 1, 1997
gc.set(Calendar.HOUR, 0);
gc.set(Calendar.AM_PM, Calendar.AM);
gc.set(Calendar.MINUTE, 0);
gc.set(Calendar.SECOND, 0);
gc.set(Calendar.MILLISECOND, 0);
gc.set(Calendar.HOUR, 0);
gc.set(Calendar.AM_PM, Calendar.AM);
gc.set(Calendar.MINUTE, 0);
gc.set(Calendar.SECOND, 0);
gc.set(Calendar.MILLISECOND, 0);
Date cd = gc.getTime();
java.util.Calendar cal = java.util.Calendar.getInstance(javazone);
cal.clear();
cal.set(1997, 3, 1, 0, 0, 0);
Date exp = cal.getTime();
if (!cd.equals(exp))
errln("Fail: Calendar.set broken. Got " + cd + " Want " + exp);
Date cd = gc.getTime();
java.util.Calendar cal = java.util.Calendar.getInstance(javazone);
cal.clear();
cal.set(1997, 3, 1, 0, 0, 0);
Date exp = cal.getTime();
if (!cd.equals(exp))
errln("Fail: Calendar.set broken. Got " + cd + " Want " + exp);
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void Test4061476() {
@ -272,17 +295,19 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* Get the associated date starting from a specified date
* NOTE: the unnecessary "getTime()'s" below are a work-around for a
* bug in jdk 1.1.3 (and probably earlier versions also)
* Get the associated date starting from a specified date NOTE: the
* unnecessary "getTime()'s" below are a work-around for a bug in jdk 1.1.3
* (and probably earlier versions also)
* <p>
* @param d The date to start from
*
* @param d
* The date to start from
*/
public static Date getAssociatedDate(Date d) {
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(d);
//cal.add(field, amount); //<-- PROBLEM SEEN WITH field = DATE,MONTH
// cal.getTime(); // <--- REMOVE THIS TO SEE BUG
//cal.add(field, amount); //<-- PROBLEM SEEN WITH field = DATE,MONTH
// cal.getTime(); // <--- REMOVE THIS TO SEE BUG
while (true) {
int wd = cal.get(Calendar.DAY_OF_WEEK);
if (wd == Calendar.SATURDAY || wd == Calendar.SUNDAY) {
@ -305,7 +330,8 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
cal.set(1997, Calendar.AUGUST, 12); // Wednesday
// cal.getTime(); // Force update
cal.setLenient(lenient);
cal.set(1996, Calendar.DECEMBER, 1); // Set the date to be December 1, 1996
cal.set(1996, Calendar.DECEMBER, 1); // Set the date to be December 1,
// 1996
int dow = cal.get(Calendar.DAY_OF_WEEK);
int min = cal.getMinimum(Calendar.DAY_OF_WEEK);
int max = cal.getMaximum(Calendar.DAY_OF_WEEK);
@ -319,7 +345,8 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
public void Test4071385() {
// work around bug for jdk1.4 on solaris 2.6, which uses funky timezone names
// work around bug for jdk1.4 on solaris 2.6, which uses funky timezone
// names
// jdk1.4.1 will drop support for 2.6 so we should be ok when it comes out
java.util.TimeZone javazone = java.util.TimeZone.getTimeZone("GMT");
TimeZone icuzone = TimeZone.getTimeZone("GMT");
@ -410,12 +437,11 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
public void Test4092362() {
GregorianCalendar cal1 = new GregorianCalendar(1997, 10, 11, 10, 20, 40);
/*cal1.set( Calendar.YEAR, 1997 );
cal1.set( Calendar.MONTH, 10 );
cal1.set( Calendar.DATE, 11 );
cal1.set( Calendar.HOUR, 10 );
cal1.set( Calendar.MINUTE, 20 );
cal1.set( Calendar.SECOND, 40 ); */
/*
* cal1.set( Calendar.YEAR, 1997 ); cal1.set( Calendar.MONTH, 10 );
* cal1.set( Calendar.DATE, 11 ); cal1.set( Calendar.HOUR, 10 );
* cal1.set( Calendar.MINUTE, 20 ); cal1.set( Calendar.SECOND, 40 );
*/
logln( " Cal1 = " + cal1.getTime().getTime() );
logln( " Cal1 time in ms = " + cal1.get(Calendar.MILLISECOND) );
@ -424,12 +450,11 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
GregorianCalendar cal2 = new GregorianCalendar(1997, 10, 11, 10, 20, 40);
/*cal2.set( Calendar.YEAR, 1997 );
cal2.set( Calendar.MONTH, 10 );
cal2.set( Calendar.DATE, 11 );
cal2.set( Calendar.HOUR, 10 );
cal2.set( Calendar.MINUTE, 20 );
cal2.set( Calendar.SECOND, 40 ); */
/*
* cal2.set( Calendar.YEAR, 1997 ); cal2.set( Calendar.MONTH, 10 );
* cal2.set( Calendar.DATE, 11 ); cal2.set( Calendar.HOUR, 10 );
* cal2.set( Calendar.MINUTE, 20 ); cal2.set( Calendar.SECOND, 40 );
*/
logln( " Cal2 = " + cal2.getTime().getTime() );
logln( " Cal2 time in ms = " + cal2.get(Calendar.MILLISECOND) );
@ -460,8 +485,8 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
logln("GMT 1 is: " + (h1=cal1.get(Calendar.HOUR_OF_DAY)));
cal1.setTime(new Date(880698639000L));
logln("GMT 2 is: " + (h2=cal1.get(Calendar.HOUR_OF_DAY)));
// Note: This test had a bug in it. It wanted h1!=h2, when
// what was meant was h1!=p. Fixed this concurrent with fix
// Note: This test had a bug in it. It wanted h1!=h2, when
// what was meant was h1!=p. Fixed this concurrent with fix
// to 4177484.
if (p == h1 || h1 != h2)
errln("Fail: Hour same in different zones");
@ -593,7 +618,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
//logln();
// Now compute the time from the fields, and make sure we
// get the same answer back. This is a round-trip test.
// get the same answer back. This is a round-trip test.
Date save = testCal.getTime();
testCal.clear();
testCal.set(Calendar.YEAR, DATA[j+1+i] < 25 ? 1998 : 1997);
@ -812,7 +837,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
final int ROLL = 2;
long[] DATA = {
// Start Action Amt Expected_change
// Start Action Amt Expected_change
onset - ONE_HOUR, ADD, 1, ONE_HOUR,
onset, ADD, -1, -ONE_HOUR,
onset - ONE_HOUR, ROLL, 1, ONE_HOUR,
@ -884,13 +909,13 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
// I am disabling this test -- it is currently failing because of a bug
// in Sun's latest change to STZ.getOffset(). I have filed a Sun bug
// in Sun's latest change to STZ.getOffset(). I have filed a Sun bug
// against this problem.
// Re-enabled after 'porting' TZ and STZ from java.util to com.ibm.icu.util.
/**
* Prove that GregorianCalendar is proleptic (it used to cut off
* at 45 BC, and not have leap years before then).
* Prove that GregorianCalendar is proleptic (it used to cut off at 45 BC,
* and not have leap years before then).
*/
public void Test4125892() {
GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
@ -909,19 +934,21 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
/**
* Calendar and GregorianCalendar hashCode() methods need improvement.
* Calendar needs a good implementation that subclasses can override,
* and GregorianCalendar should use that implementation.
* Calendar needs a good implementation that subclasses can override, and
* GregorianCalendar should use that implementation.
*/
public void Test4136399() {
/* Note: This test is actually more strict than it has to be.
/*
* Note: This test is actually more strict than it has to be.
* Technically, there is no requirement that unequal objects have
* unequal hashes. We only require equal objects to have equal hashes.
* unequal hashes. We only require equal objects to have equal hashes.
* It is desirable for unequal objects to have distributed hashes, but
* there is no hard requirement here.
*
*
* In this test we make assumptions about certain attributes of calendar
* objects getting represented in the hash, which need not always be the
* case (although it does work currently with the given test). */
* case (although it does work currently with the given test).
*/
Calendar a = Calendar.getInstance();
Calendar b = (Calendar)a.clone();
if (a.hashCode() != b.hashCode()) {
@ -973,7 +1000,8 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
GregorianCalendar cal = new GregorianCalendar();
GregorianCalendar cal2 = (GregorianCalendar)cal.clone();
Date cut = cal.getGregorianChange();
Date cut2 = new Date(cut.getTime() + 100*24*60*60*1000L); // 100 days later
Date cut2 = new Date(cut.getTime() + 100*24*60*60*1000L); // 100 days
// later
if (!cal.equals(cal2)) {
errln("Cloned GregorianCalendars not equal");
}
@ -984,8 +1012,8 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* Bug states that ArrayIndexOutOfBoundsException is thrown by GregorianCalendar.roll()
* when IllegalArgumentException should be.
* Bug states that ArrayIndexOutOfBoundsException is thrown by
* GregorianCalendar.roll() when IllegalArgumentException should be.
*/
public void Test4142933() {
GregorianCalendar calendar = new GregorianCalendar();
@ -1007,9 +1035,9 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
/**
* GregorianCalendar handling of Dates Long.MIN_VALUE and Long.MAX_VALUE is
* confusing; unless the time zone has a raw offset of zero, one or the
* other of these will wrap. We've modified the test given in the bug
* report to therefore only check the behavior of a calendar with a zero raw
* offset zone.
* other of these will wrap. We've modified the test given in the bug report
* to therefore only check the behavior of a calendar with a zero raw offset
* zone.
*/
public void Test4145158() {
GregorianCalendar calendar = new GregorianCalendar();
@ -1048,10 +1076,10 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* This is a bug in the validation code of GregorianCalendar. As reported,
* This is a bug in the validation code of GregorianCalendar. As reported,
* the bug seems worse than it really is, due to a bug in the way the bug
* report test was written. In reality the bug is restricted to the DAY_OF_YEAR
* field. - liu 6/29/98
* report test was written. In reality the bug is restricted to the
* DAY_OF_YEAR field. - liu 6/29/98
*/
public void Test4147269() {
GregorianCalendar calendar = new GregorianCalendar();
@ -1063,7 +1091,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
for (int field = 0; field < calendar.getFieldCount(); field++) {
calendar.setTime(date);
// Note: In the bug report, getActualMaximum() was called instead
// of getMaximum() -- this was an error. The validation code doesn't
// of getMaximum() -- this was an error. The validation code doesn't
// use getActualMaximum(), since that's too costly.
int max = calendar.getMaximum(field);
int value = max+1;
@ -1083,9 +1111,9 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* Reported bug is that a GregorianCalendar with a cutover of Date(Long.MAX_VALUE)
* doesn't behave as a pure Julian calendar.
* CANNOT REPRODUCE THIS BUG
* Reported bug is that a GregorianCalendar with a cutover of
* Date(Long.MAX_VALUE) doesn't behave as a pure Julian calendar. CANNOT
* REPRODUCE THIS BUG
*/
public void Test4149677() {
TimeZone[] zones = { TimeZone.getTimeZone("GMT"),
@ -1117,8 +1145,8 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* Calendar and Date HOUR broken. If HOUR is out-of-range, Calendar
* and Date classes will misbehave.
* Calendar and Date HOUR broken. If HOUR is out-of-range, Calendar and Date
* classes will misbehave.
*/
public void Test4162587() {
TimeZone tz = TimeZone.getTimeZone("PST");
@ -1175,18 +1203,15 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* GregorianCalendar.getActualMaximum() does not account for first day of week.
* GregorianCalendar.getActualMaximum() does not account for first day of
* week.
*/
public void Test4166109() {
/* Test month:
*
* March 1998
* Su Mo Tu We Th Fr Sa
* 1 2 3 4 5 6 7
* 8 9 10 11 12 13 14
* 15 16 17 18 19 20 21
* 22 23 24 25 26 27 28
* 29 30 31
/*
* Test month:
*
* March 1998 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
* 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
*/
boolean passed = true;
int field = Calendar.WEEK_OF_MONTH;
@ -1227,7 +1252,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
GregorianCalendar calendars[] = {
new GregorianCalendar(100, Calendar.NOVEMBER, 1),
new GregorianCalendar(-99 /*100BC*/, Calendar.JANUARY, 1),
new GregorianCalendar(-99 /* 100BC */, Calendar.JANUARY, 1),
new GregorianCalendar(1996, Calendar.FEBRUARY, 29),
};
@ -1259,16 +1284,18 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
calendar.set(field, years[i]);
Date dateAfter = calendar.getTime();
int newYear = calendar.get(field);
calendar.setTime(dateBefore); // restore calendar for next use
calendar.setTime(dateBefore); // restore calendar for next
// use
logln(" Year " + years[i] + (valid? " ok " : " bad") +
" => " + format.format(dateAfter));
if (valid && newYear != years[i]) {
errln(" FAIL: " + newYear + " should be valid; date, month and time shouldn't change");
} else if (!valid && newYear == years[i]) {
// We no longer require strict year maxima. That is, the calendar
// We no longer require strict year maxima. That is, the
// calendar
// algorithm may work for values > the stated maximum.
//errln(" FAIL: " + newYear + " should be invalid");
//errln(" FAIL: " + newYear + " should be invalid");
logln(" Note: " + newYear + " > maximum, but still valid");
}
}
@ -1277,8 +1304,8 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* Calendar.roll broken
* This bug relies on the TimeZone bug 4173604 to also be fixed.
* Calendar.roll broken This bug relies on the TimeZone bug 4173604 to also
* be fixed.
*/
public void Test4173516() {
int fieldsList[][] = {
@ -1460,16 +1487,12 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* Calendar DAY_OF_WEEK_IN_MONTH fields->time broken. The problem
* is in the field disambiguation code in GregorianCalendar. This
* code is supposed to choose the most recent set of fields
* among the following:
*
* MONTH + DAY_OF_MONTH
* MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
* MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
* DAY_OF_YEAR
* WEEK_OF_YEAR + DAY_OF_WEEK
* Calendar DAY_OF_WEEK_IN_MONTH fields->time broken. The problem is in the
* field disambiguation code in GregorianCalendar. This code is supposed to
* choose the most recent set of fields among the following:
*
* MONTH + DAY_OF_MONTH MONTH + WEEK_OF_MONTH + DAY_OF_WEEK MONTH +
* DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK DAY_OF_YEAR WEEK_OF_YEAR + DAY_OF_WEEK
*/
public void Test4209071() {
Calendar cal = Calendar.getInstance(Locale.US);
@ -1522,7 +1545,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
// 4
new int[] { Calendar.DAY_OF_MONTH, 18,
Calendar.DAY_OF_WEEK, Calendar.THURSDAY, }, d[4],
// 5 (WOM -1 is in previous month)
// 5 (WOM -1 is in previous month)
new int[] { Calendar.DAY_OF_MONTH, 18,
Calendar.WEEK_OF_MONTH, -1,
Calendar.DAY_OF_WEEK, Calendar.THURSDAY, }, d[5],
@ -1530,7 +1553,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
new int[] { Calendar.DAY_OF_MONTH, 18,
Calendar.WEEK_OF_MONTH, 4,
Calendar.DAY_OF_WEEK, Calendar.THURSDAY, }, d[6],
// 7 (DIM -1 is in same month)
// 7 (DIM -1 is in same month)
new int[] { Calendar.DAY_OF_MONTH, 18,
Calendar.DAY_OF_WEEK_IN_MONTH, -1,
Calendar.DAY_OF_WEEK, Calendar.THURSDAY, }, d[7],
@ -1607,8 +1630,8 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* WEEK_OF_YEAR computed incorrectly. A failure of this test can indicate
* a problem in several different places in the
* WEEK_OF_YEAR computed incorrectly. A failure of this test can indicate a
* problem in several different places in the
*/
public void Test4288792() throws Exception
{
@ -1625,12 +1648,12 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
cal.setMinimalDaysInFirstWeek(j1);
cal.setFirstDayOfWeek(j);
// Set the calendar to the first day of the last week
// of the year. This may overlap some of the start of
// of the year. This may overlap some of the start of
// the next year; that is, the last week of 1999 may
// include some of January 2000. Use the add() method
// to advance through the week. For each day, call
// get(WEEK_OF_YEAR). The result should be the same
// for the whole week. Note that a bug in
// include some of January 2000. Use the add() method
// to advance through the week. For each day, call
// get(WEEK_OF_YEAR). The result should be the same
// for the whole week. Note that a bug in
// getActualMaximum() will break this test.
cal.set(Calendar.YEAR, i);
int maxWeek = cal.getActualMaximum(Calendar.WEEK_OF_YEAR);
@ -1645,7 +1668,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
+ ",min=" + j1 + ",first=" + j);
}
}
// Now advance the calendar one more day. This should
// Now advance the calendar one more day. This should
// put it at the first day of week 1 of the next year.
cal.add(Calendar.DATE, 1);
int WOY = cal.get(Calendar.WEEK_OF_YEAR);
@ -1710,7 +1733,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* Set behavior of DST_OFFSET field. ICU4J Jitterbug 9.
* Set behavior of DST_OFFSET field. ICU4J Jitterbug 9.
*/
public void TestJ9() {
int HOURS = 60*60*1000;
@ -1781,13 +1804,11 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
/**
* DateFormat class mistakes date style and time style as follows:
* - DateFormat.getDateTimeInstance takes date style as time
* style, and time style as date style
* - If a Calendar is passed to
* DateFormat.getDateInstance, it returns time instance
* - If a Calendar
* is passed to DateFormat.getTimeInstance, it returns date instance
* DateFormat class mistakes date style and time style as follows: -
* DateFormat.getDateTimeInstance takes date style as time style, and time
* style as date style - If a Calendar is passed to
* DateFormat.getDateInstance, it returns time instance - If a Calendar is
* passed to DateFormat.getTimeInstance, it returns date instance
*/
public void TestDateFormatFactoryJ26() {
TimeZone zone = TimeZone.getDefault();
@ -1849,48 +1870,41 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
public void TestRegistration() {
/*
Set names = Calendar.getCalendarFactoryNames();
TimeZone tz = TimeZone.getDefault();
Locale loc = Locale.getDefault();
Iterator iter = names.iterator();
while (iter.hasNext()) {
String name = (String)iter.next();
logln("Testing factory: " + name);
Calendar cal = Calendar.getInstance(tz, loc, name);
logln("Calendar class: " + cal.getClass());
DateFormat fmt = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.LONG, loc);
logln("Date: " + fmt.format(cal.getTime()));
}
// register new default for our locale
logln("\nTesting registration");
loc = new Locale("en", "US");
Object key = Calendar.register(JapaneseCalendar.factory(), loc, true);
loc = new Locale("en", "US", "TEST");
Calendar cal = Calendar.getInstance(loc);
logln("Calendar class: " + cal.getClass());
DateFormat fmt = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.LONG, loc);
logln("Date: " + fmt.format(cal.getTime()));
// force to use other default anyway
logln("\nOverride registration");
cal = Calendar.getInstance(tz, loc, "Gregorian");
fmt = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.LONG, loc);
logln("Date: " + fmt.format(cal.getTime()));
// unregister default
logln("\nUnregistration");
logln("Unregister returned: " + Calendar.unregister(key));
cal = Calendar.getInstance(tz, loc, "Gregorian");
fmt = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.LONG, loc);
logln("Date: " + fmt.format(cal.getTime()));
*/
* Set names = Calendar.getCalendarFactoryNames();
*
* TimeZone tz = TimeZone.getDefault(); Locale loc =
* Locale.getDefault(); Iterator iter = names.iterator(); while
* (iter.hasNext()) { String name = (String)iter.next(); logln("Testing
* factory: " + name);
*
* Calendar cal = Calendar.getInstance(tz, loc, name); logln("Calendar
* class: " + cal.getClass());
*
* DateFormat fmt = cal.getDateTimeFormat(DateFormat.LONG,
* DateFormat.LONG, loc);
*
* logln("Date: " + fmt.format(cal.getTime())); }
* // register new default for our locale logln("\nTesting
* registration"); loc = new Locale("en", "US"); Object key =
* Calendar.register(JapaneseCalendar.factory(), loc, true);
*
* loc = new Locale("en", "US", "TEST"); Calendar cal =
* Calendar.getInstance(loc); logln("Calendar class: " +
* cal.getClass()); DateFormat fmt =
* cal.getDateTimeFormat(DateFormat.LONG, DateFormat.LONG, loc);
* logln("Date: " + fmt.format(cal.getTime()));
* // force to use other default anyway logln("\nOverride
* registration"); cal = Calendar.getInstance(tz, loc, "Gregorian"); fmt =
* cal.getDateTimeFormat(DateFormat.LONG, DateFormat.LONG, loc);
* logln("Date: " + fmt.format(cal.getTime()));
* // unregister default logln("\nUnregistration"); logln("Unregister
* returned: " + Calendar.unregister(key)); cal =
* Calendar.getInstance(tz, loc, "Gregorian"); fmt =
* cal.getDateTimeFormat(DateFormat.LONG, DateFormat.LONG, loc);
* logln("Date: " + fmt.format(cal.getTime()));
*/
}
}
//eof

View File

@ -522,7 +522,8 @@ public class ChineseTest extends CalendarTest {
public void TestCoverage() {
ChineseCalendar cal = new ChineseCalendar();
ChineseDateFormat fmt = (ChineseDateFormat)DateFormat.getInstance(cal);
DateFormat format = DateFormat.getInstance(cal);
ChineseDateFormat fmt = (ChineseDateFormat)format;
fmt.applyPattern("llyyll");
Date time = getDate(2100, Calendar.JANUARY, 1);
String str = fmt.format(time);

View File

@ -118,103 +118,107 @@ public class HebrewTest extends CalendarTest {
* work properly for a wide range of data.
*/
public void TestCases() {
doTestCases(testCases, new HebrewCalendar());
try{
final TestCase[] testCases = {
//
// Most of these test cases were taken from the back of
// "Calendrical Calculations", with some extras added to help
// debug a few of the problems that cropped up in development.
//
// The months in this table are 1-based rather than 0-based,
// because it's easier to edit that way.
//
// Julian Day Era Year Month Day WkDay Hour Min Sec
new TestCase(1507231.5, 0, 3174, 12, 10, SUN, 0, 0, 0),
new TestCase(1660037.5, 0, 3593, 3, 25, WED, 0, 0, 0),
new TestCase(1746893.5, 0, 3831, 1, 3, WED, 0, 0, 0),
new TestCase(1770641.5, 0, 3896, 1, 9, SUN, 0, 0, 0),
new TestCase(1892731.5, 0, 4230, 4, 18, WED, 0, 0, 0),
new TestCase(1931579.5, 0, 4336, 10, 4, MON, 0, 0, 0),
new TestCase(1974851.5, 0, 4455, 2, 13, SAT, 0, 0, 0),
new TestCase(2091164.5, 0, 4773, 9, 6, SUN, 0, 0, 0),
new TestCase(2121509.5, 0, 4856, 9, 23, SUN, 0, 0, 0),
new TestCase(2155779.5, 0, 4950, 8, 7, FRI, 0, 0, 0),
new TestCase(2174029.5, 0, 5000, 7, 8, SAT, 0, 0, 0),
new TestCase(2191584.5, 0, 5048, 8, 21, FRI, 0, 0, 0),
new TestCase(2195261.5, 0, 5058, 9, 7, SUN, 0, 0, 0),
new TestCase(2229274.5, 0, 5151, 11, 1, SUN, 0, 0, 0),
new TestCase(2245580.5, 0, 5196, 5, 7, WED, 0, 0, 0),
new TestCase(2266100.5, 0, 5252, 8, 3, SAT, 0, 0, 0),
new TestCase(2288542.5, 0, 5314, 1, 1, SAT, 0, 0, 0),
new TestCase(2290901.5, 0, 5320, 6, 27, SAT, 0, 0, 0),
new TestCase(2323140.5, 0, 5408, 10, 20, WED, 0, 0, 0),
new TestCase(2334551.5, 0, 5440, 1, 1, THU, 0, 0, 0),
new TestCase(2334581.5, 0, 5440, 2, 1, SAT, 0, 0, 0),
new TestCase(2334610.5, 0, 5440, 3, 1, SUN, 0, 0, 0),
new TestCase(2334639.5, 0, 5440, 4, 1, MON, 0, 0, 0),
new TestCase(2334668.5, 0, 5440, 5, 1, TUE, 0, 0, 0),
new TestCase(2334698.5, 0, 5440, 6, 1, THU, 0, 0, 0),
new TestCase(2334728.5, 0, 5440, 7, 1, SAT, 0, 0, 0),
new TestCase(2334757.5, 0, 5440, 8, 1, SUN, 0, 0, 0),
new TestCase(2334787.5, 0, 5440, 9, 1, TUE, 0, 0, 0),
new TestCase(2334816.5, 0, 5440, 10, 1, WED, 0, 0, 0),
new TestCase(2334846.5, 0, 5440, 11, 1, FRI, 0, 0, 0),
new TestCase(2334848.5, 0, 5440, 11, 3, SUN, 0, 0, 0),
new TestCase(2334934.5, 0, 5441, 1, 1, TUE, 0, 0, 0),
new TestCase(2348020.5, 0, 5476, 12, 5, FRI, 0, 0, 0),
new TestCase(2366978.5, 0, 5528, 11, 4, SUN, 0, 0, 0),
new TestCase(2385648.5, 0, 5579, 12, 11, MON, 0, 0, 0),
new TestCase(2392825.5, 0, 5599, 8, 12, WED, 0, 0, 0),
new TestCase(2416223.5, 0, 5663, 8, 22, SUN, 0, 0, 0),
new TestCase(2425848.5, 0, 5689, 12, 19, SUN, 0, 0, 0),
new TestCase(2430266.5, 0, 5702, 1, 8, MON, 0, 0, 0),
new TestCase(2430833.5, 0, 5703, 8, 14, MON, 0, 0, 0),
new TestCase(2431004.5, 0, 5704, 1, 8, THU, 0, 0, 0),
new TestCase(2448698.5, 0, 5752, 7, 12, TUE, 0, 0, 0),
new TestCase(2450138.5, 0, 5756, 7, 5, SUN, 0, 0, 0),
new TestCase(2465737.5, 0, 5799, 2, 12, WED, 0, 0, 0),
new TestCase(2486076.5, 0, 5854, 12, 5, SUN, 0, 0, 0),
// Additional test cases for bugs found during development
// G.YY/MM/DD Era Year Month Day WkDay Hour Min Sec
new TestCase(1013, 9, 8, 0, 4774, 1, 1, TUE, 0, 0, 0),
new TestCase(1239, 9, 1, 0, 5000, 1, 1, THU, 0, 0, 0),
new TestCase(1240, 9,18, 0, 5001, 1, 1, TUE, 0, 0, 0),
// Test cases taken from a table of 14 "year types" in the Help file
// of the application "Hebrew Calendar"
new TestCase(2456187.5, 0, 5773, 1, 1, MON, 0, 0, 0),
new TestCase(2459111.5, 0, 5781, 1, 1, SAT, 0, 0, 0),
new TestCase(2453647.5, 0, 5766, 1, 1, TUE, 0, 0, 0),
new TestCase(2462035.5, 0, 5789, 1, 1, THU, 0, 0, 0),
new TestCase(2458756.5, 0, 5780, 1, 1, MON, 0, 0, 0),
new TestCase(2460586.5, 0, 5785, 1, 1, THU, 0, 0, 0),
new TestCase(2463864.5, 0, 5794, 1, 1, SAT, 0, 0, 0),
new TestCase(2463481.5, 0, 5793, 1, 1, MON, 0, 0, 0),
new TestCase(2470421.5, 0, 5812, 1, 1, THU, 0, 0, 0),
new TestCase(2460203.5, 0, 5784, 1, 1, SAT, 0, 0, 0),
new TestCase(2459464.5, 0, 5782, 1, 1, TUE, 0, 0, 0),
new TestCase(2467142.5, 0, 5803, 1, 1, MON, 0, 0, 0),
new TestCase(2455448.5, 0, 5771, 1, 1, THU, 0, 0, 0),
// Test cases for JB#2327
// http://www.fourmilab.com/documents/calendar/
// http://www.calendarhome.com/converter/
// 2452465.5, 2002, JULY, 10, 5762, AV, 1,
// 2452494.5, 2002, AUGUST, 8, 5762, AV, 30,
// 2452495.5, 2002, AUGUST, 9, 5762, ELUL, 1,
// 2452523.5, 2002, SEPTEMBER, 6, 5762, ELUL, 29,
// 2452524.5, 2002, SEPTEMBER, 7, 5763, TISHRI, 1,
// Julian Day Era Year Month Day WkDay Hour Min Sec
new TestCase(2452465.5, 0, 5762, AV+1, 1, WED, 0, 0, 0),
new TestCase(2452494.5, 0, 5762, AV+1, 30, THU, 0, 0, 0),
new TestCase(2452495.5, 0, 5762, ELUL+1, 1, FRI, 0, 0, 0),
new TestCase(2452523.5, 0, 5762, ELUL+1, 29, FRI, 0, 0, 0),
new TestCase(2452524.5, 0, 5763,TISHRI+1, 1, SAT, 0, 0, 0),
};
doTestCases(testCases, new HebrewCalendar());
}catch(Exception ex){
warnln("Got Exception: "+ ex.getMessage());
}
}
static final TestCase[] testCases = {
//
// Most of these test cases were taken from the back of
// "Calendrical Calculations", with some extras added to help
// debug a few of the problems that cropped up in development.
//
// The months in this table are 1-based rather than 0-based,
// because it's easier to edit that way.
//
// Julian Day Era Year Month Day WkDay Hour Min Sec
new TestCase(1507231.5, 0, 3174, 12, 10, SUN, 0, 0, 0),
new TestCase(1660037.5, 0, 3593, 3, 25, WED, 0, 0, 0),
new TestCase(1746893.5, 0, 3831, 1, 3, WED, 0, 0, 0),
new TestCase(1770641.5, 0, 3896, 1, 9, SUN, 0, 0, 0),
new TestCase(1892731.5, 0, 4230, 4, 18, WED, 0, 0, 0),
new TestCase(1931579.5, 0, 4336, 10, 4, MON, 0, 0, 0),
new TestCase(1974851.5, 0, 4455, 2, 13, SAT, 0, 0, 0),
new TestCase(2091164.5, 0, 4773, 9, 6, SUN, 0, 0, 0),
new TestCase(2121509.5, 0, 4856, 9, 23, SUN, 0, 0, 0),
new TestCase(2155779.5, 0, 4950, 8, 7, FRI, 0, 0, 0),
new TestCase(2174029.5, 0, 5000, 7, 8, SAT, 0, 0, 0),
new TestCase(2191584.5, 0, 5048, 8, 21, FRI, 0, 0, 0),
new TestCase(2195261.5, 0, 5058, 9, 7, SUN, 0, 0, 0),
new TestCase(2229274.5, 0, 5151, 11, 1, SUN, 0, 0, 0),
new TestCase(2245580.5, 0, 5196, 5, 7, WED, 0, 0, 0),
new TestCase(2266100.5, 0, 5252, 8, 3, SAT, 0, 0, 0),
new TestCase(2288542.5, 0, 5314, 1, 1, SAT, 0, 0, 0),
new TestCase(2290901.5, 0, 5320, 6, 27, SAT, 0, 0, 0),
new TestCase(2323140.5, 0, 5408, 10, 20, WED, 0, 0, 0),
new TestCase(2334551.5, 0, 5440, 1, 1, THU, 0, 0, 0),
new TestCase(2334581.5, 0, 5440, 2, 1, SAT, 0, 0, 0),
new TestCase(2334610.5, 0, 5440, 3, 1, SUN, 0, 0, 0),
new TestCase(2334639.5, 0, 5440, 4, 1, MON, 0, 0, 0),
new TestCase(2334668.5, 0, 5440, 5, 1, TUE, 0, 0, 0),
new TestCase(2334698.5, 0, 5440, 6, 1, THU, 0, 0, 0),
new TestCase(2334728.5, 0, 5440, 7, 1, SAT, 0, 0, 0),
new TestCase(2334757.5, 0, 5440, 8, 1, SUN, 0, 0, 0),
new TestCase(2334787.5, 0, 5440, 9, 1, TUE, 0, 0, 0),
new TestCase(2334816.5, 0, 5440, 10, 1, WED, 0, 0, 0),
new TestCase(2334846.5, 0, 5440, 11, 1, FRI, 0, 0, 0),
new TestCase(2334848.5, 0, 5440, 11, 3, SUN, 0, 0, 0),
new TestCase(2334934.5, 0, 5441, 1, 1, TUE, 0, 0, 0),
new TestCase(2348020.5, 0, 5476, 12, 5, FRI, 0, 0, 0),
new TestCase(2366978.5, 0, 5528, 11, 4, SUN, 0, 0, 0),
new TestCase(2385648.5, 0, 5579, 12, 11, MON, 0, 0, 0),
new TestCase(2392825.5, 0, 5599, 8, 12, WED, 0, 0, 0),
new TestCase(2416223.5, 0, 5663, 8, 22, SUN, 0, 0, 0),
new TestCase(2425848.5, 0, 5689, 12, 19, SUN, 0, 0, 0),
new TestCase(2430266.5, 0, 5702, 1, 8, MON, 0, 0, 0),
new TestCase(2430833.5, 0, 5703, 8, 14, MON, 0, 0, 0),
new TestCase(2431004.5, 0, 5704, 1, 8, THU, 0, 0, 0),
new TestCase(2448698.5, 0, 5752, 7, 12, TUE, 0, 0, 0),
new TestCase(2450138.5, 0, 5756, 7, 5, SUN, 0, 0, 0),
new TestCase(2465737.5, 0, 5799, 2, 12, WED, 0, 0, 0),
new TestCase(2486076.5, 0, 5854, 12, 5, SUN, 0, 0, 0),
// Additional test cases for bugs found during development
// G.YY/MM/DD Era Year Month Day WkDay Hour Min Sec
new TestCase(1013, 9, 8, 0, 4774, 1, 1, TUE, 0, 0, 0),
new TestCase(1239, 9, 1, 0, 5000, 1, 1, THU, 0, 0, 0),
new TestCase(1240, 9,18, 0, 5001, 1, 1, TUE, 0, 0, 0),
// Test cases taken from a table of 14 "year types" in the Help file
// of the application "Hebrew Calendar"
new TestCase(2456187.5, 0, 5773, 1, 1, MON, 0, 0, 0),
new TestCase(2459111.5, 0, 5781, 1, 1, SAT, 0, 0, 0),
new TestCase(2453647.5, 0, 5766, 1, 1, TUE, 0, 0, 0),
new TestCase(2462035.5, 0, 5789, 1, 1, THU, 0, 0, 0),
new TestCase(2458756.5, 0, 5780, 1, 1, MON, 0, 0, 0),
new TestCase(2460586.5, 0, 5785, 1, 1, THU, 0, 0, 0),
new TestCase(2463864.5, 0, 5794, 1, 1, SAT, 0, 0, 0),
new TestCase(2463481.5, 0, 5793, 1, 1, MON, 0, 0, 0),
new TestCase(2470421.5, 0, 5812, 1, 1, THU, 0, 0, 0),
new TestCase(2460203.5, 0, 5784, 1, 1, SAT, 0, 0, 0),
new TestCase(2459464.5, 0, 5782, 1, 1, TUE, 0, 0, 0),
new TestCase(2467142.5, 0, 5803, 1, 1, MON, 0, 0, 0),
new TestCase(2455448.5, 0, 5771, 1, 1, THU, 0, 0, 0),
// Test cases for JB#2327
// http://www.fourmilab.com/documents/calendar/
// http://www.calendarhome.com/converter/
// 2452465.5, 2002, JULY, 10, 5762, AV, 1,
// 2452494.5, 2002, AUGUST, 8, 5762, AV, 30,
// 2452495.5, 2002, AUGUST, 9, 5762, ELUL, 1,
// 2452523.5, 2002, SEPTEMBER, 6, 5762, ELUL, 29,
// 2452524.5, 2002, SEPTEMBER, 7, 5763, TISHRI, 1,
// Julian Day Era Year Month Day WkDay Hour Min Sec
new TestCase(2452465.5, 0, 5762, AV+1, 1, WED, 0, 0, 0),
new TestCase(2452494.5, 0, 5762, AV+1, 30, THU, 0, 0, 0),
new TestCase(2452495.5, 0, 5762, ELUL+1, 1, FRI, 0, 0, 0),
new TestCase(2452523.5, 0, 5762, ELUL+1, 29, FRI, 0, 0, 0),
new TestCase(2452524.5, 0, 5763,TISHRI+1, 1, SAT, 0, 0, 0),
};
/**
* Problem reported by Armand Bendanan in which setting of the MONTH
* field in a Hebrew calendar causes the time fields to go negative.

View File

@ -75,13 +75,13 @@ public class IBMCalendarTest extends CalendarTest {
Calendar.MONDAY, Calendar.WEEKDAY,
Calendar.FRIDAY, Calendar.WEEKDAY,
Calendar.SATURDAY, Calendar.WEEKEND,
Calendar.SUNDAY, Calendar.WEEKEND,
Calendar.SUNDAY, Calendar.WEEKEND_CEASE,
},
new Locale("ar", "BH"), new int[] { // Thursday:Friday
Calendar.WEDNESDAY,Calendar.WEEKDAY,
Calendar.SATURDAY, Calendar.WEEKDAY,
Calendar.THURSDAY, Calendar.WEEKEND,
Calendar.FRIDAY, Calendar.WEEKEND,
Calendar.FRIDAY, Calendar.WEEKEND_CEASE,
},
};

View File

@ -510,7 +510,7 @@ public class CollationAPITest extends TestFmwk {
}
logln("Test getVersion");
VersionInfo expectedVersion = VersionInfo.getInstance(0x29, 0x80, 0x01, 0x04);
VersionInfo expectedVersion = VersionInfo.getInstance(0x29, 0x80, 0x00, 0x04);
doAssert(col.getVersion().equals(expectedVersion), "Expected version "+expectedVersion.toString()+" got "+col.getVersion().toString());
logln("Test getUCAVersion");

View File

@ -18,6 +18,7 @@ import com.ibm.icu.dev.test.util.BNF;
import com.ibm.icu.dev.test.util.BagFormatter;
import com.ibm.icu.dev.test.util.Quoter;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
@ -53,7 +54,7 @@ public class RandomCollator extends TestFmwk {
// }
if(skipIfBeforeICU(3,0)) return;
String fileName;
PrintWriter pw = BagFormatter.openUTF8Writer("", "RandomCollationTestLog.txt");
PrintWriter pw = BagFormatter.openUTF8Writer(System.getProperty("user.dir")+File.separator, "RandomCollationTestLog.txt");
TestCollator tc = new TestCollator(chars);
pw.println("Collation Test Run");
pw.println("Note: For parse-exception, " + POSITION + " indicates the errorOffset");

View File

@ -139,21 +139,22 @@ public class DateFormatMiscTests extends com.ibm.icu.dev.test.TestFmwk {
}
final String zones[][] = symbols.getZoneStrings();
int index = zones.length-3;
//int rowCount = zones.length, colCount = zones[0].length; //The variable is never used
logln("Long zone name = " + zones[24][1]);
if (!zones[24][1].equals(jstLong)) {
logln("Long zone name = " + zones[index][1]);
if (!zones[index][1].equals(jstLong)) {
errln("*** Should have been " + jstLong);
}
logln("Short zone name = " + zones[24][2]);
if (!zones[24][2].equals(jstShort)) {
logln("Short zone name = " + zones[index][2]);
if (!zones[index][2].equals(jstShort)) {
errln("*** Should have been " + jstShort);
}
logln("Long zone name = " + zones[24][3]);
if (!zones[24][3].equals(jstLong)) {
logln("Long zone name = " + zones[index][3]);
if (!zones[index][3].equals(jstLong)) {
errln("*** Should have been " + jstLong +" instead of "+zones[0][3]);
}
logln("SHORT zone name = " + zones[24][4]);
if (!zones[24][4].equals(jstShort)) {
logln("SHORT zone name = " + zones[index][4]);
if (!zones[index][4].equals(jstShort)) {
errln("*** Should have been " + jstShort);
}
}

View File

@ -207,7 +207,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
"Wednesday", "", "", "", "", "PM", "2", "", "PDT", "", "", "", "", "", "",
"", "1997", "ao\u00FBt", "13", "", "14", "34", "", "",
"mercredi", "", "", "", "", "", "", "", "PDT", "", "", "", "", "", "",
"mercredi", "", "", "", "", "", "", "", "HAP (\u00C9UA)", "", "", "", "", "", "",
"AD", "1997", "8", "13", "14", "14", "34", "12", "5",
"Wed", "225", "2", "33", "3", "PM", "2", "2", "PDT", "1997", "4", "1997", "2450674", "52452513", "-0700",
@ -766,7 +766,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
TimeZone tz = TimeZone.getTimeZone("PST");
dfFrench.setTimeZone(tz);
dfUS.setTimeZone(tz);
String expectedFRENCH_JDK12 = "lundi 15 septembre 1997 00 h 00 PDT";
String expectedFRENCH_JDK12 = "lundi 15 septembre 1997 00 h 00 HAP (\u00C9UA)";
//String expectedFRENCH = "lundi 15 septembre 1997 00 h 00 PDT";
String expectedUS = "Monday, September 15, 1997 12:00:00 AM PDT";
logln("Date set to : " + testDate);
@ -1291,24 +1291,30 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
// create DFS that recognizes our bogus time zone, sortof
DateFormatSymbols xsym = new DateFormatSymbols();
String[][] tzids = xsym.getZoneStrings();
boolean changedGMT = false;
for (int i = 0; i < tzids.length; ++i) {
if (tzids[i][0].equals("GMT")) {
if (tzids[i][0].equals("Etc/GMT")) {
tzids[i][1] = "DBDY"; // change a local name
logln("replaced GMT with DBDY");
changedGMT = true;
break;
}
}
xsym.setZoneStrings(tzids);
fmt.setDateFormatSymbols(xsym);
try {
fmt.parse(text);
logln("we parsed DBDY (as GMT, but still...)");
}
catch (ParseException e) {
errln("hey, still didn't recognize DBDY");
}
finally {
TimeZone.setDefault(oldtz);
if(changedGMT==true){
try {
fmt.parse(text);
logln("we parsed DBDY (as GMT, but still...)");
}
catch (ParseException e) {
errln("hey, still didn't recognize DBDY");
}
finally {
TimeZone.setDefault(oldtz);
}
}else{
errln("Could not find Etc/GMT in the tzids returned.");
}
}

View File

@ -102,6 +102,7 @@ public class TestUScript extends TestFmwk {
}
}else{
numErrors++;
logln("Error getting script code for name "+testNames[i]);
}
}
reportDataErrors(numErrors);

View File

@ -19,57 +19,13 @@ public class NormalizerPerformanceTest extends PerfTest {
}
protected void setup(String[] args) {
if (args.length < 2) {
printUsage();
}
String path = "";
String encoding = "UTF-8";
String fileName = "";
boolean bulkMode = false;
boolean lineMode = false;
for (int i = 0; i < args.length; i++) {
if (args[i].equalsIgnoreCase("-f") || args[i].equalsIgnoreCase("--fileName")) {
if (((i + 1) >= args.length) || (args[i+1].charAt(0) == '-')) {
printUsage();
} else {
fileName = args[i+1];
}
}
if (args[i].equalsIgnoreCase("-s") || args[i].equalsIgnoreCase("--sourceDir") ) {
if (((i + 1) >= args.length) || (args[i+1].charAt(0) == '-')) {
printUsage();
} else {
path = args[i+1];
String fileseparator = System.getProperty("file.separator", "/");
if (path.charAt(path.length() - 1) != fileseparator.charAt(0)) {
path = path + fileseparator;
}
}
}
if (args[i].equalsIgnoreCase("-e") || args[i].equalsIgnoreCase("--encoding")) {
if (((i + 1) >= args.length) || (args[i+1].charAt(0) == '-')) {
printUsage();
} else {
encoding = args[i+1];
}
}
if (args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("--bulkMode")) {
bulkMode = true;
lineMode = false;
}
if (args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("--lineMode")) {
bulkMode = false;
lineMode = true;
}
}
if(lineMode == bulkMode){
if(bulk_mode == line_mode){
printUsage();
}
if (fileName.equalsIgnoreCase("")){
printUsage();
}
fileLines = readLines(path + fileName, encoding, bulkMode);
fileLines = readLines(fileName, encoding, bulk_mode);
NFDFileLines = normalizeInput(fileLines, Normalizer.NFD);
NFCFileLines = normalizeInput(fileLines, Normalizer.NFC);
}

View File

@ -246,15 +246,13 @@ public abstract class PerfTest {
//bufferLen = 0;
verbose = false;
bulk_mode = false;
passes = 3; // default
iterations = 0;
time = 3; // default
passes = iterations = time = 0;
locale = null;
UOption[] options = getOptions();
int remainingArgc = UOption.parseArgs(args, options);
if(options[HELP1].doesOccur || options[HELP2].doesOccur) {
if(args.length==0 || options[HELP1].doesOccur || options[HELP2].doesOccur) {
throw new UsageException();
}
@ -320,6 +318,7 @@ public abstract class PerfTest {
int i, j;
for (i=0; i<remainingArgc; ++i) {
// is args[i] a method name?
Method m = getTestMethod(args[i]);
if (m != null) {
@ -333,12 +332,7 @@ public abstract class PerfTest {
break;
}
if (methodList.size() < 1) { // default to all methods
System.out.println("running all methods");
methodList.addAll(getAvailableTests().values());
}
if (options[LIST].doesOccur) {
if (methodList.size() < 1 || options[LIST].doesOccur) {
System.err.println("Available tests:");
Iterator methods = getAvailableTests().values().iterator();
TreeSet methodNames = new TreeSet();
@ -349,7 +343,10 @@ public abstract class PerfTest {
while (tests.hasNext()) {
System.err.println(" " + tests.next());
}
return;
if (options[LIST].doesOccur) {
System.exit(0);
}
throw new UsageException("Must specify at least one method name");
}
// Pass remaining arguments, if any, through to the subclass
@ -381,37 +378,80 @@ public abstract class PerfTest {
throw new RuntimeException(meth.getName() + " returned an illegal operations/iteration()");
}
// System.out.println("passes: " + passes + " iterations: " + iterations);
int n;
long t;
for (j=0; j<passes; ++j) {
// ---------------------------------------------------------------------------------------------------
//The rest of this method is modified by GCL Shanghai. To synchronize this class with ICU4C's uperf.cpp
//----------------------------------------------------------------------------------------------------
long loops = 0;
//for (j=0; j<passes; ++j) {
if (iterations > 0) {
// Run specified number of iterations
System.out.println("= " + meth.getName() + " begin " + iterations + " iterations");
t = testFunction.time(iterations);
System.out.println("= " + meth.getName() + " end " + (t/1000.0) + " " + testFunction.getOperationsPerIteration());
loops = iterations;
// System.out.println("= " + meth.getName() + " begin " + iterations + " iterations");
// t = testFunction.time(iterations);
// System.out.println("= " + meth.getName() + " end " + (t/1000.0) + " " + testFunction.getOperationsPerIteration());
} else {
// Run for specified duration in seconds
System.out.println("= " + meth.getName() + " begin " + time + " seconds");
//first calibrate to determine iterations/pass
if (verbose) {
System.out.println("= " + meth.getName() + " calibrating " + time + " seconds" );
}
n = time * 1000; // s => ms
//System.out.println("# " + meth.getName() + " " + n + " sec");
int loops = 0;
int failsafe = 1; // last resort for very fast methods
t = 0;
while (t < n) {
if (t < 100) {
while (t < (int)(n * 0.9)) { // 90% is close enough
if (loops == 0 || t == 0) {
loops = failsafe;
failsafe *= 2;
failsafe *= 10;
} else {
//System.out.println("# " + meth.getName() + " x " + loops + " = " + t);
loops = Math.max(loops+1, (int)((double)n / t * loops + 0.5));
loops = (int)((double)n / t * loops + 0.5);
if (loops == 0) {
throw new RuntimeException("Unable to converge on desired duration");
}
}
//System.out.println("# " + meth.getName() + " x " + loops);
t = testFunction.time(loops);
}
System.out.println("= " + meth.getName() + " end " + (t/1000.0) + " " + testFunction.getOperationsPerIteration() +
" " + loops);
}
//}
for (j=0; j<passes; ++j) {
long events = -1;
if (verbose) {
if (iterations > 0) {
System.out.println("= " + meth.getName() + " begin " + iterations);
} else {
System.out.println("= " + meth.getName() + " begin " + time + " seconds");
}
} else {
System.out.println("= " + meth.getName() + " begin " );
}
t = testFunction.time(loops); //ms
events = testFunction.getEventsPerIteration();
if (verbose) {
if (events == -1){
System.out.println("= " + meth.getName() + " end " + (t/1000.0) + " loops: " + loops +
" operations: " + testFunction.getOperationsPerIteration());
} else {
System.out.println("= " + meth.getName() + " end " + (t/1000.0) + " loops: " + loops +
" operations: " + testFunction.getOperationsPerIteration() +" events: " + events);
}
} else {
if (events == -1){
System.out.println("= " + meth.getName() + " end " + (t/1000.0) + " " + loops +
" " + testFunction.getOperationsPerIteration());
} else {
System.out.println("= " + meth.getName() + " end " + (t/1000.0) + " " + loops +
" " + testFunction.getOperationsPerIteration() + " " + events);
}
}
}
}
}

View File

@ -17,20 +17,23 @@ my $TESTCLASS = 'com.ibm.icu.dev.test.perf.NormalizerPerformanceTest';
# Methods to be tested. Each pair represents a test method and
# a baseline method which is used for comparison.
my @METHODS = (['TestICU_NFC_NFC_Text', 'TestJDK_NFC_NFC_Text'],
my @METHODS = (
['TestICU_NFD_NFC_Text', 'TestJDK_NFD_NFC_Text'],
['TestICU_NFC_NFC_Text', 'TestJDK_NFC_NFC_Text'],
['TestICU_NFC_NFD_Text', 'TestJDK_NFC_NFD_Text'],
['TestICU_NFC_Orig_Text', 'TestJKD_NFC_Orig_Text'],
['TestICU_NFD_NFC_Text', 'TestJDK_NFD_NFC_Text'],
['TestICU_NFD_NFC_Text', 'TestJDK_NFD_NFC_Text'],
['TestICU_NFD_NFD_Text', 'TestJDK_NFD_NFD_Text'],
['TestICU_NFD_Orig_Text', 'TestJDK_NFD_Orig_Text'],
);
# Patterns which define the set of characters used for testing.
my $SOURCEDIR ="c:\\work\\DevICU\\icu\\source\\test\\perf\\normperf\\text\\";
my $SOURCEDIR ="C:\\work\\icu4j\\src\\com\\ibm\\icu\\dev\\test\\perf\\data\\collation\\";
my @OPTIONS = (
# src text src encoding mode
[ "TestNames_SerbianSH.txt", "UTF-8", "b"],
[ "arabic.txt", "UTF-8", "b"],
[ "french.txt", "UTF-8", "b"],
[ "greek.txt", "UTF-8", "b"],
@ -257,7 +260,7 @@ sub measure1 {
# calibrate: estimate ms/iteration
print "Calibrating...";
my @t = callJava($method, $pat, -$CALIBRATE);
my @t = callJava($method, $pat, $CALIBRATE );
print "done.\n";
my @data = split(/\s+/, $t[0]->[2]);
@ -319,7 +322,7 @@ sub callJava {
my $pat = shift;
my $n = shift;
my $fileName = $SOURCEDIR . @$pat[0] ;
my $cmd = "c:\\j2sdk1.4.0\\bin\\java -classpath ;classes; $TESTCLASS $method $n -f $fileName -e @$pat[1] -@$pat[2]";
my $cmd = "c:\\jdk1.4.2_04\\bin\\java -classpath ;classes; $TESTCLASS $method -t $n -f $fileName -e @$pat[1] -@$pat[2]";
print "[$cmd]\n"; # for debugging
open(PIPE, "$cmd|") or die "Can't run \"$cmd\"";
my @out;

View File

@ -344,6 +344,10 @@ public class ArabicShapingRegTest extends TestFmwk {
catch (Exception e) {
ex = e;
}
catch (InternalError ie){
warnln("InternalError: "+ie.toString());
return;
}
if (!test.result.equals(result)) {
reportTestFailure(i, test, shaper, result, ex);

View File

@ -27,17 +27,17 @@ public class TimeZoneRegression extends TestFmwk {
public void Test4052967() {
logln("*** CHECK TIMEZONE AGAINST HOST OS SETTING ***");
String id = TimeZone.getDefault().getID();
try {
// user.timezone is a protected system property
logln("user.timezone: " + System.getProperty("user.timezone", "<not set>"));
logln("TimeZone.getDefault().getID(): " + id);
logln(new Date().toString());
logln("*** THE RESULTS OF THIS TEST MUST BE VERIFIED MANUALLY ***");
}
catch (SecurityException e) {
warnln("security exception: " + e.toString());
}
String id = TimeZone.getDefault().getID();
try {
// user.timezone is a protected system property
logln("user.timezone: " + System.getProperty("user.timezone", "<not set>"));
logln("TimeZone.getDefault().getID(): " + id);
logln(new Date().toString());
logln("*** THE RESULTS OF THIS TEST MUST BE VERIFIED MANUALLY ***");
}
catch (SecurityException e) {
warnln("security exception: " + e.toString());
}
}
public void Test4073209() {

View File

@ -6,8 +6,12 @@
*/
package com.ibm.icu.dev.test.util;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.MissingResourceException;
import java.util.Enumeration;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.impl.ICUData;
@ -26,6 +30,26 @@ public final class ICUResourceBundleTest extends TestFmwk {
test.run(args);
}
public void TestGetResources(){
try{
ClassLoader loader = getClass().getClassLoader();
Enumeration enum = loader.getResources("META-INF");
for(;enum.hasMoreElements();){
//URL url = loader.getResource("LocaleElements_en.class");
//File file = new File(url.getPath());
URL url = (URL)enum.nextElement();
File file = new File(url.getPath());
File[] files = file.listFiles();
if(files!=null){
for(int i=0; i<files.length; i++){
logln(files[i].getName());
}
}
}
}catch(Exception ex){
errln("Unexpected exception: "+ ex.getMessage());
}
}
public void TestResourceBundleWrapper(){
UResourceBundle bundle = UResourceBundle.getBundleInstance("com.ibm.icu.impl.data.HolidayBundle", "da_DK");
Object o = bundle.getObject("holidays");
@ -430,7 +454,7 @@ public final class ICUResourceBundleTest extends TestFmwk {
sub = rb1.get("testGetStringByKeyAliasing" );
s1 = sub.get("KeyAlias0PST").getString();
if(s1.equals("PST")){
if(s1.equals("America/Los_Angeles")){
logln("Alias mechanism works for KeyAlias0PST");
}else{
errln("Did not get the expected output for KeyAlias0PST");
@ -459,7 +483,7 @@ public final class ICUResourceBundleTest extends TestFmwk {
{
sub = rb.get("testGetStringByIndexAliasing" );
s1 = sub.getString(0);
if(s1.equals("PST")){
if(s1.equals("America/Los_Angeles")){
logln("Alias mechanism works for testGetStringByIndexAliasing/0. Got: "+s1);
}else{
errln("Did not get the expected output for testGetStringByIndexAliasing/0. Got: "+s1);
@ -540,7 +564,8 @@ public final class ICUResourceBundleTest extends TestFmwk {
}
public void TestGetWithFallback(){
ICUResourceBundle bundle =(ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,"te_IN");
/*
ICUResourceBundle bundle =(ICUResourceBundle) UResourceBundle.getBundleInstance("com/ibm/icu/dev/data/testdata","te_IN");
String key = bundle.getStringWithFallback("Keys/collation");
if(!key.equals("COLLATION")){
errln("Did not get the expected result from getStringWithFallback method.");
@ -549,7 +574,9 @@ public final class ICUResourceBundleTest extends TestFmwk {
if(!type.equals("DIRECT")){
errln("Did not get the expected result form getStringWithFallback method.");
}
*/
ICUResourceBundle bundle = null;
String key = null;
try{
bundle = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_COLLATION_BASE_NAME,ULocale.canonicalize("de__PHONEBOOK"));
if(!bundle.getULocale().equals("de")){
@ -683,7 +710,7 @@ public final class ICUResourceBundleTest extends TestFmwk {
try{
ICUResourceBundle rb = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "no_NO_NY");
ICUResourceBundle sub = rb.get("Countries");
String s1 = sub.getString(1);
String s1 = sub.getString("NO");
if(s1.equals("Noreg")){
logln("got expected output ");
}else{

View File

@ -851,7 +851,7 @@ public class ULocaleTest extends TestFmwk {
if(locales.length<10){
errln("Did not get the correct result from getAvailableLocales");
}
if(!locales[locales.length-1].equals("zh_TW")){
if(!locales[locales.length-1].equals("zh_Hant_TW")){
errln("Did not get the expected result");
}
}

View File

@ -87,7 +87,10 @@ public class CalendarData {
public String[] getStringArray(String key, String subKey) {
return get(key, subKey).getStringArray();
}
public String[] getEras(String subkey){
UResourceBundle bundle = get("eras");
return bundle.getStringArray(subkey);
}
public ULocale getULocale() {
return fBundle.getULocale();
}

View File

@ -56,7 +56,18 @@ public abstract class ICUResourceBundle extends UResourceBundle{
*/
public static final String ICU_COLLATION_BASE_NAME = ICU_BASE_NAME + "/coll";
/**
* The base name of rbnf data to be used with getBundleInstance API
* @draft ICU 3.0
*/
public static final String ICU_RBNF_BASE_NAME = ICU_BASE_NAME + "/rbnf";
/**
* The base name of transliterator data to be used with getBundleInstance API
* @draft ICU 3.0
*/
public static final String ICU_TRANSLIT_BASE_NAME = ICU_BASE_NAME + "/translit";
/**
* The class loader constant to be used with getBundleInstance API
* @draft ICU 3.0

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:591653615e884f9d765c702ef63896b76a4e342166fcfc8aa97f0961e05d6670
size 1687123
oid sha256:54695b7ca8ec85fda7460a8cf5fa0dc097eea8e5cb45cf2971b83e35faa9cbbf
size 1906975

View File

@ -2,10 +2,10 @@ Manifest-Version: 1.0
Name: com/ibm/icu
Specification-Title: Modularized ICU for Java
Specification-Version: 3.0
Specification-Version: 3.2
Specification-Vendor: ICU
Implementation-Title: Modularized ICU for Java
Implementation-Version: 3.0.0
Implementation-Version: 3.2.0
Implementation-Vendor: IBM Corporation
Implementation-Vendor-Id: com.ibm
Copyright-Info: Copyright (c) 2000-2004, International Business Machines Corporation and others. All Rights Reserved.

View File

@ -2,10 +2,10 @@ Manifest-Version: 1.0
Name: com/ibm/icu/
Specification-Title: ICU for Java
Specification-Version: 3.0
Specification-Version: 3.2
Specification-Vendor: ICU
Implementation-Title: ICU for Java
Implementation-Version: 3.0.0
Implementation-Version: 3.2.0
Implementation-Vendor: IBM Corporation
Implementation-Vendor-Id: com.ibm
Copyright-Info: Copyright (c) 2000-2004, International Business Machines Corporation and others. All Rights Reserved.

View File

@ -89,6 +89,6 @@ public class ChineseDateFormatSymbols extends DateFormatSymbols {
*/
protected void initializeData(ULocale loc, CalendarData calData) {
super.initializeData(loc, calData);
isLeapMonth = calData.getStringArray("IsLeapMonth");
isLeapMonth = calData.getStringArray("isLeapMonth");
}
}

View File

@ -448,7 +448,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
// FIXME: cache only ResourceBundle. Hence every time, will do
// getObject(). This won't be necessary if the Resource itself
// is cached.
eras = calData.getStringArray("eras");
eras = calData.getEras("abbreviated");
months = calData.getStringArray("monthNames", "wide");
shortMonths = calData.getStringArray("monthNames", "abbreviated");

View File

@ -556,8 +556,7 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
infinity = numberElements[9];
NaN = numberElements[10];
// TODO Temporarily hard code; retrieve from resource later
plusSign = DecimalFormat.PATTERN_PLUS_SIGN;
plusSign =numberElements[11].charAt(0);
padEscape = DecimalFormat.PATTERN_PAD_ESCAPE;
sigDigit = DecimalFormat.PATTERN_SIGNIFICANT_DIGIT;
@ -582,9 +581,9 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
currencySymbol = "\u00A4"; // 'OX' currency symbol
}
// If there is a currency decimal, use it.
// monetarySeparator =
// numberElements[numberElements.length >= 12 ? 11 : 0].charAt(0);
monetarySeparator = numberElements[11].charAt(0);
monetarySeparator =
numberElements[0].charAt(0);
//monetarySeparator = numberElements[11].charAt(0);
}
/**

View File

@ -1907,11 +1907,13 @@ public final class Normalizer implements Cloneable {
* @throws IllegalArgumentException if the given index is less than
* {@link #getBeginIndex} or greater than {@link #getEndIndex}.
* @return The codepoint as an int
* @deprecated ICU 3.2
* @obsolete ICU 3.2
*/
// public int setIndex(int index) {
// setIndexOnly(index);
// return current();
// }
public int setIndex(int index) {
setIndexOnly(index);
return current();
}
/**
* Retrieve the index of the start of the input text. This is the begin

View File

@ -1246,7 +1246,7 @@ public abstract class Transliterator {
// root will change to sun.text.resources.LocaleElements
ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.
getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, inLocale);
getBundleInstance(ICUResourceBundle.ICU_TRANSLIT_BASE_NAME, inLocale);
// Normalize the ID
String stv[] = TransliteratorIDParser.IDtoSTV(id);

View File

@ -119,7 +119,7 @@ class TransliteratorRegistry {
// If 'top' is not a script name, try a locale lookup
if (script == UScript.INVALID_CODE) {
Locale toploc = LocaleUtility.getLocaleFromName(top);
res = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,toploc);
res = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_TRANSLIT_BASE_NAME,toploc);
// Make sure we got the bundle we wanted; otherwise, don't use it
if (res!=null && LocaleUtility.isFallbackOf(res.getULocale().toString(), top)) {
isSpecLocale = true;

View File

@ -127,7 +127,7 @@ public class Currency extends MeasureUnit implements Serializable {
if (variant.equals("PREEURO") || variant.equals("EURO")) {
country = country + '_' + variant;
}
ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,"root");
ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,"CurrencyData");
ICUResourceBundle cm = bundle.get("CurrencyMap");
// Do a linear search
@ -582,7 +582,7 @@ public class Currency extends MeasureUnit implements Serializable {
// Get CurrencyMeta resource out of root locale file. [This may
// move out of the root locale file later; if it does, update this
// code.]
ICUResourceBundle root = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,"root");
ICUResourceBundle root = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,"CurrencyData");
ICUResourceBundle currencyMeta = root.get("CurrencyMeta");
//Integer[] i = null;

View File

@ -370,7 +370,7 @@ public final class ULocale implements Serializable {
};
String[] tempObsoleteLanguages = {
"in", "iw", "ji", "jw", "sh", "no", /* obsolete language codes */
"in", "iw", "ji", "jw", "sh", "no", /* obsolete language codes */
};
/* This list MUST contain a three-letter code for every two-letter code in the
@ -696,7 +696,7 @@ public final class ULocale implements Serializable {
{ "uz_UZ_CYRL", "uz_Cyrl_UZ", null, null }, /* .NET name */
{ "uz_UZ_LATN", "uz_Latn_UZ", null, null }, /* .NET name */
{ "zh_CHS", "zh_Hans", null, null }, /* .NET name */
{ "zh_CHT", "zh_TW", null, null }, /* .NET name TODO: This should be zh_Hant once the locale structure is fixed. */
{ "zh_CHT", "zh_Hant", null, null }, /* .NET name TODO: This should be zh_Hant once the locale structure is fixed. */
{ "zh_GAN", "zh__GAN", null, null }, /* registered name */
{ "zh_GUOYU", "zh", null, null }, /* registered name */
{ "zh_HAKKA", "zh__HAKKA", null, null }, /* registered name */

View File

@ -108,7 +108,7 @@ public final class VersionInfo
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
public static final String ICU_DATA_VERSION = "30b";
public static final String ICU_DATA_VERSION = "32b";
/**
* ICU4J collator runtime version
@ -384,7 +384,7 @@ public final class VersionInfo
UNICODE_3_1_1 = getInstance(3, 1, 1, 0);
UNICODE_3_2 = getInstance(3, 2, 0, 0);
UNICODE_4_0 = getInstance(4, 0, 0, 0);
ICU_VERSION = getInstance(3, 0, 0, 0);
ICU_VERSION = getInstance(3, 2, 0, 0);
UCOL_RUNTIME_VERSION = getInstance(5);
UCOL_BUILDER_VERSION = getInstance(6);
UCOL_TAILORINGS_VERSION = getInstance(1);