/*
*******************************************************************************
- * Copyright (C) 2007-2010, International Business Machines Corporation and *
+ * Copyright (C) 2007-2013, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
logln(caseString + " SUCCESS: got=expected="+toDate);
logln("PASS: "+caseString+" matched! ");
} else {
- if (caseString.equals("[case 31]") && TimeZone.getDefaultTimeZoneType() == TimeZone.TIMEZONE_JDK) {
+ // Note: With JDK TimeZone implementation, tz offset on dates earlier than
+ // mid-1900 might be different from the TZDB. Following test cases are
+ // failing because of this.
+ if ((caseString.equals("[case 31]") || caseString.equals("[case 36]"))
+ && TimeZone.getDefaultTimeZoneType() == TimeZone.TIMEZONE_JDK) {
logln(caseString + " FAIL(expected): got " +
toCalendar.getTimeInMillis() + " expected " +
toDate);
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
+import java.util.TreeSet;
import java.util.regex.Pattern;
import com.ibm.icu.impl.ZoneMeta;
public class TimeZoneFormatTest extends com.ibm.icu.dev.test.TestFmwk {
- public static void main(String[] args) throws Exception {
+ private static boolean JDKTZ = (TimeZone.getDefaultTimeZoneType() == TimeZone.TIMEZONE_JDK);
+
+ public static void main(String[] args) throws Exception {
new TimeZoneFormatTest().run(args);
}
LOCALES = new ULocale[] {new ULocale("en"), new ULocale("en_CA"), new ULocale("fr"), new ULocale("zh_Hant")};
}
- String[] tzids = TimeZone.getAvailableIDs();
+ String[] tzids;
+ if (JDKTZ) {
+ tzids = java.util.TimeZone.getAvailableIDs();
+ } else {
+ tzids = TimeZone.getAvailableIDs();
+ }
int[] inOffsets = new int[2];
int[] outOffsets = new int[2];
} else {
// Specific or generic: raw offset must be preserved.
if (inOffsets[0] != outOffsets[0]) {
- if (TimeZone.getDefaultTimeZoneType() == TimeZone.TIMEZONE_JDK
- && tzids[tzidx].startsWith("SystemV/")) {
+ if (JDKTZ && tzids[tzidx].startsWith("SystemV/")) {
// JDK uses rule SystemV for these zones while
// ICU handles these zones as aliases of existing time zones
if (REALLY_VERBOSE_LOG) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern, LOCALES[locidx]);
boolean minutesOffset = MINUTES_OFFSET.contains(PATTERNS[patidx]);
- Set<String> ids = TimeZone.getAvailableIDs(SystemTimeZoneType.CANONICAL, null, null);
+ Set<String> ids = null;
+ if (JDKTZ) {
+ ids = new TreeSet<String>();
+ String[] jdkIDs = java.util.TimeZone.getAvailableIDs();
+ for (String jdkID : jdkIDs) {
+ String tmpID = TimeZone.getCanonicalID(jdkID);
+ if (tmpID != null) {
+ ids.add(tmpID);
+ }
+ }
+ } else {
+ ids = TimeZone.getAvailableIDs(SystemTimeZoneType.CANONICAL, null, null);
+ }
+
for (String id : ids) {
if (PATTERNS[patidx].equals("V")) {
// Some zones do not have short ID assigned, such as Asia/Riyadh87.