Java Code Examples for java.util.TimeZone#getAvailableIDs()

The following examples show how to use java.util.TimeZone#getAvailableIDs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectTimezoneFunction.java    From GpsPrune with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Use the system information to populate the list of available timezones
 */
private void collectTimezoneInfo()
{
	_zoneInfo = new ArrayList<TimezoneDetails>();
	for (String id : TimeZone.getAvailableIDs())
	{
		String region = getRegion(id);
		if (region != null)
		{
			TimeZone tz = TimeZone.getTimeZone(id);
			TimezoneDetails details = new TimezoneDetails();
			details._id = id;
			details._region = region;
			details._offset = tz.getOffset(System.currentTimeMillis()) / 1000 / 60;
			details._group = tz.getDisplayName();
			details._name = getNameWithoutRegion(id);
			_zoneInfo.add(details);
		}
	}
}
 
Example 2
Source File: SPDateTimeUtil.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Get browser time zone or fixed time zone if configured
 *
 * @return TimeZone
 */
public static TimeZone getBrowserTimeZone() {


    if (!StringUtils.isEmpty(fixedTimeZoneProperty)) {
        return TimeZone.getTimeZone(fixedTimeZoneProperty);
    }

    final WebBrowser webBrowser = com.vaadin.server.Page.getCurrent().getWebBrowser();
    final String[] timeZones = TimeZone.getAvailableIDs(webBrowser.getRawTimezoneOffset());
    TimeZone tz = TimeZone.getDefault();
    for (final String string : timeZones) {
        final TimeZone t = TimeZone.getTimeZone(string);
        if (t.getRawOffset() == webBrowser.getRawTimezoneOffset()) {
            tz = t;
        }
    }
    return tz;
}
 
Example 3
Source File: DateFormatSymbols.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public String[][] getZoneStrings() {
	synchronized (this) {
		if (zoneStrings == null) {
			String ids[] = TimeZone.getAvailableIDs();
			String newZoneStrings[][] = new String[ids.length][5];
			for (int i = 0; i < ids.length; i++) {
				newZoneStrings[i][ZONE_ID] = ids[i]; // - time zone ID
				String key = ids[i].toUpperCase();
				newZoneStrings[i][ZONE_LONGNAME] = getLocalizedValue(L10N_ZONE_LONGNAME + key, ids[i]);
				newZoneStrings[i][ZONE_SHORTNAME] = getLocalizedValue(L10N_ZONE_SHORTNAME + key, ids[i]);
				newZoneStrings[i][ZONE_LONGNAME_DST] = getLocalizedValue(L10N_ZONE_LONGNAME_DST + key, ids[i]);
				newZoneStrings[i][ZONE_SHORTNAME_DST] = getLocalizedValue(L10N_ZONE_SHORTNAME_DST + key, ids[i]);
			}
			zoneStrings = newZoneStrings;
		}
	}
	return zoneStrings;
}
 
Example 4
Source File: TimezoneManagementController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Displays list of all JRE available timezones.
    */
   @RequestMapping("/start")
   public String unspecified(@ModelAttribute TimezoneForm timezoneForm, HttpServletRequest request) throws Exception {
List<Timezone> defaultTimezones = timezoneService.getDefaultTimezones();

ArrayList<TimezoneDTO> timezoneDtos = new ArrayList<>();
for (String availableTimezoneId : TimeZone.getAvailableIDs()) {
    boolean isSelected = defaultTimezones.contains(new Timezone(availableTimezoneId));
    TimeZone timeZone = TimeZone.getTimeZone(availableTimezoneId);
    TimezoneDTO timezoneDto = TimezoneDTO.createTimezoneDTO(timeZone, isSelected);
    timezoneDtos.add(timezoneDto);
}

request.setAttribute("timezoneDtos", timezoneDtos);
request.setAttribute("serverTimezone", timezoneService.getServerTimezone().getTimezoneId());

return "timezoneManagement";
   }
 
Example 5
Source File: ValueMetaBaseSerializationTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private static ValueMetaBase createTestObject( int storageType ) {
  ValueMetaBase vmb = new ValueMetaBase( "test", ValueMetaInterface.TYPE_STRING );
  vmb.setStorageType( storageType );
  vmb.setLength( 10, 5 );
  vmb.setOrigin( "origin" );
  vmb.setComments( "comments" );
  vmb.setConversionMask( "conversionMask" );
  vmb.setDecimalSymbol( "decimalSymbol" );
  vmb.setGroupingSymbol( "groupingSymbol" );
  vmb.setCurrencySymbol( "currencySymbol" );
  vmb.setTrimType( ValueMetaInterface.TRIM_TYPE_BOTH );
  vmb.setCaseInsensitive( true );
  vmb.setSortedDescending( true );
  vmb.setOutputPaddingEnabled( true );
  vmb.setDateFormatLenient( true );
  vmb.setLenientStringToNumber( true );
  vmb.setDateFormatLocale( Locale.JAPAN );
  vmb.setCollatorDisabled( false );
  vmb.setCollatorLocale( Locale.JAPANESE );
  vmb.setCollatorStrength( 1 );

  String[] zones = TimeZone.getAvailableIDs();
  vmb.setDateFormatTimeZone( TimeZone.getTimeZone( zones[ new Random().nextInt( zones.length ) ] ) );

  return vmb;
}
 
Example 6
Source File: OlsonTimeZoneTest.java    From ews-java-api with MIT License 6 votes vote down vote up
@Test
public void testOlsonTimeZoneConversion() {
  final Map<String, String> olsonTimeZoneToMsMap = TimeZoneUtils.createOlsonTimeZoneToMsMap();
  final String[] timeZoneIds = TimeZone.getAvailableIDs();

  for (final String timeZoneId : timeZoneIds) {
    final boolean america = timeZoneId.startsWith("America");
    final boolean europe = timeZoneId.startsWith("Europe");
    final boolean africa = timeZoneId.startsWith("Africa");

    if (america || europe || africa) {
      // There are a few timezones that are out of date or don't have direct microsoft mappings
      // according to the Unicode source we use so we will only test Americas, Europe and Africa.
      final TimeZone timeZone = TimeZone.getTimeZone(timeZoneId);
      final OlsonTimeZoneDefinition olsonTimeZone = new OlsonTimeZoneDefinition(timeZone);
      final String olsonTimeZoneId = olsonTimeZone.getId();

      Assert.assertFalse("olsonTimeZoneId for " + timeZoneId + " is blank", StringUtils.isBlank(olsonTimeZoneId));
      Assert.assertEquals(olsonTimeZoneToMsMap.get(timeZoneId), olsonTimeZoneId);
    }
  }
}
 
Example 7
Source File: TimeUtil.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loads a properties file that contains all kinds of time zone mappings.
 * 
 * @param exceptionInterceptor
 *            exception interceptor
 */
private static void loadTimeZoneMappings(ExceptionInterceptor exceptionInterceptor) {
    timeZoneMappings = new Properties();
    try {
        timeZoneMappings.load(TimeUtil.class.getResourceAsStream(TIME_ZONE_MAPPINGS_RESOURCE));
    } catch (IOException e) {
        throw ExceptionFactory.createException(Messages.getString("TimeUtil.LoadTimeZoneMappingError"), exceptionInterceptor);
    }
    // bridge all Time Zone ids known by Java
    for (String tz : TimeZone.getAvailableIDs()) {
        if (!timeZoneMappings.containsKey(tz)) {
            timeZoneMappings.put(tz, tz);
        }
    }
}
 
Example 8
Source File: UtcDateTypeAdapterTest.java    From gson with Apache License 2.0 5 votes vote down vote up
public void testDifferentTimeZones() {
  for (String timeZone : TimeZone.getAvailableIDs()) {
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timeZone));
    Date expected = cal.getTime();
    String json = gson.toJson(expected);
    // System.out.println(json + ": " + timeZone);
    Date actual = gson.fromJson(json, Date.class);
    assertEquals(expected.getTime(), actual.getTime());
  }
}
 
Example 9
Source File: CalendarRegression.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void Test4040996() {
    String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
    SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
    pdt.setStartRule(APRIL, 1, SUNDAY, 2 * 60 * 60 * 1000);
    pdt.setEndRule(OCTOBER, -1, SUNDAY, 2 * 60 * 60 * 1000);
    Calendar calendar = new GregorianCalendar(pdt);

    calendar.set(MONTH, 3);
    calendar.set(DAY_OF_MONTH, 18);
    calendar.set(SECOND, 30);

    logln("MONTH: " + calendar.get(MONTH));
    logln("DAY_OF_MONTH: "
            + calendar.get(DAY_OF_MONTH));
    logln("MINUTE: " + calendar.get(MINUTE));
    logln("SECOND: " + calendar.get(SECOND));

    calendar.add(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(MONTH));
    logln("DAY_OF_MONTH: "
            + calendar.get(DAY_OF_MONTH));
    logln("MINUTE: " + calendar.get(MINUTE));
    logln("SECOND: " + calendar.get(SECOND));
    if (calendar.get(MONTH) != 3
            || calendar.get(DAY_OF_MONTH) != 18
            || calendar.get(SECOND) != 36) {
        errln("Fail: Calendar.add misbehaves");
    }
}
 
Example 10
Source File: AstrosoftTimeZone.java    From Astrosoft with GNU General Public License v2.0 5 votes vote down vote up
public static AstrosoftTimeZone[] availableTimeZones(){
	String ids[] = TimeZone.getAvailableIDs();
	AstrosoftTimeZone tzs[] = new AstrosoftTimeZone[ids.length];
	
	int i = 0;
	for(String id : ids){
		tzs[i++] = new AstrosoftTimeZone(id);
	}
	return tzs;
}
 
Example 11
Source File: TimeZoneService.java    From staffjoy with MIT License 5 votes vote down vote up
public TimeZoneList listTimeZones() {
    TimeZoneList timeZoneList = TimeZoneList.builder().build();
    for(String id : TimeZone.getAvailableIDs()) {
        timeZoneList.getTimezones().add(id);
    }
    return timeZoneList;
}
 
Example 12
Source File: TimeZoneRandomizer.java    From easy-random with MIT License 4 votes vote down vote up
@Override
public TimeZone getRandomValue() {
    String[] timeZoneIds = TimeZone.getAvailableIDs();
    return TimeZone.getTimeZone(timeZoneIds[random.nextInt(timeZoneIds.length)]);
}
 
Example 13
Source File: Bug6772689.java    From native-obfuscator with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) {
    TimeZone defaultTimeZone = TimeZone.getDefault();
    int errors = 0;

    Calendar cal = new GregorianCalendar(BEGIN_YEAR, MARCH, 1);
    String[] tzids = TimeZone.getAvailableIDs();
    try {
        for (String id : tzids) {
            TimeZone tz = TimeZone.getTimeZone(id);
            if (!tz.useDaylightTime()) {
                continue;
            }
            TimeZone.setDefault(tz);

          dateloop:
            // Use future dates because sun.util.calendar.ZoneInfo
            // delegates offset transition calculations to a SimpleTimeZone
            // (after 2038 as of JDK7).
            for (int year = BEGIN_YEAR; year < END_YEAR; year++) {
                for (int month = MARCH; month <= NOVEMBER; month++) {
                    cal.set(year, month, 1, 15, 0, 0);
                    int maxDom = cal.getActualMaximum(DAY_OF_MONTH);
                    for (int dom = 1; dom <= maxDom; dom++) {
                        Date date = new Date(year - 1900, month, dom);
                        if (date.getYear()+1900 != year
                            || date.getMonth() != month
                            || date.getDate() != dom) {
                            System.err.printf("%s: got %04d-%02d-%02d, expected %04d-%02d-%02d%n",
                                              id,
                                              date.getYear() + 1900,
                                              date.getMonth() + 1,
                                              date.getDate(),
                                              year,
                                              month + 1,
                                              dom);
                            errors++;
                            break dateloop;
                        }
                    }
                }
            }
        }
    } finally {
        // Restore the default TimeZone.
        TimeZone.setDefault(defaultTimeZone);
    }
    if (errors > 0) {
        throw new RuntimeException("Transition test failed");
    }
}
 
Example 14
Source File: TimezoneDisplayJava7.java    From tutorials with MIT License 4 votes vote down vote up
public List<String> getTimeZoneList(TimezoneDisplayJava7.OffsetBase base) {
    String[] availableZoneIds = TimeZone.getAvailableIDs();
    List<String> result = new ArrayList<>(availableZoneIds.length);

    for (String zoneId : availableZoneIds) {
        TimeZone curTimeZone = TimeZone.getTimeZone(zoneId);

        String offset = calculateOffset(curTimeZone.getRawOffset());

        result.add(String.format("(%s%s) %s", base, offset, zoneId));
    }

    Collections.sort(result);

    return result;
}
 
Example 15
Source File: Bug6772689.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    TimeZone defaultTimeZone = TimeZone.getDefault();
    int errors = 0;

    Calendar cal = new GregorianCalendar(BEGIN_YEAR, MARCH, 1);
    String[] tzids = TimeZone.getAvailableIDs();
    try {
        for (String id : tzids) {
            TimeZone tz = TimeZone.getTimeZone(id);
            if (!tz.useDaylightTime()) {
                continue;
            }
            TimeZone.setDefault(tz);

          dateloop:
            // Use future dates because sun.util.calendar.ZoneInfo
            // delegates offset transition calculations to a SimpleTimeZone
            // (after 2038 as of JDK7).
            for (int year = BEGIN_YEAR; year < END_YEAR; year++) {
                for (int month = MARCH; month <= NOVEMBER; month++) {
                    cal.set(year, month, 1, 15, 0, 0);
                    int maxDom = cal.getActualMaximum(DAY_OF_MONTH);
                    for (int dom = 1; dom <= maxDom; dom++) {
                        Date date = new Date(year - 1900, month, dom);
                        if (date.getYear()+1900 != year
                            || date.getMonth() != month
                            || date.getDate() != dom) {
                            System.err.printf("%s: got %04d-%02d-%02d, expected %04d-%02d-%02d%n",
                                              id,
                                              date.getYear() + 1900,
                                              date.getMonth() + 1,
                                              date.getDate(),
                                              year,
                                              month + 1,
                                              dom);
                            errors++;
                            break dateloop;
                        }
                    }
                }
            }
        }
    } finally {
        // Restore the default TimeZone.
        TimeZone.setDefault(defaultTimeZone);
    }
    if (errors > 0) {
        throw new RuntimeException("Transition test failed");
    }
}
 
Example 16
Source File: LuceneTestCase.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/** 
 * Return a random TimeZone from the available timezones on the system
 * @see <a href="http://issues.apache.org/jira/browse/LUCENE-4020">LUCENE-4020</a>
 */
public static TimeZone randomTimeZone(Random random) {
  String tzIds[] = TimeZone.getAvailableIDs();
  return TimeZone.getTimeZone(tzIds[random.nextInt(tzIds.length)]);
}
 
Example 17
Source File: JavatimeTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Throwable {

        int N = 10000;
        long t1970 = new java.util.Date(70, 0, 01).getTime();
        Random r = new Random();
        for (int i = 0; i < N; i++) {
            int days  = r.nextInt(50) * 365 + r.nextInt(365);
            long secs = t1970 + days * 86400 + r.nextInt(86400);
            int nanos = r.nextInt(NANOS_PER_SECOND);
            int nanos_ms = nanos / 1000000 * 1000000; // millis precision
            long millis = secs * 1000 + r.nextInt(1000);
            LocalDateTime ldt = LocalDateTime.ofEpochSecond(secs, nanos, ZoneOffset.UTC);
            LocalDateTime ldt_ms = LocalDateTime.ofEpochSecond(secs, nanos_ms, ZoneOffset.UTC);
            Instant inst = Instant.ofEpochSecond(secs, nanos);
            Instant inst_ms = Instant.ofEpochSecond(secs, nanos_ms);
            ///////////// java.util.Date /////////////////////////
            Date jud = new java.util.Date(millis);
            Instant inst0 = jud.toInstant();
            if (jud.getTime() != inst0.toEpochMilli() ||
                !jud.equals(Date.from(inst0))) {
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: j.u.d -> instant -> j.u.d");
            }
            // roundtrip only with millis precision
            Date jud0 = Date.from(inst_ms);
            if (jud0.getTime() != inst_ms.toEpochMilli() ||
                !inst_ms.equals(jud0.toInstant())) {
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: instant -> j.u.d -> instant");
            }
            //////////// java.util.GregorianCalendar /////////////
            GregorianCalendar cal = new GregorianCalendar();
            // non-roundtrip of tz name between j.u.tz and j.t.zid
            cal.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()));
            cal.setGregorianChange(new java.util.Date(Long.MIN_VALUE));
            cal.setFirstDayOfWeek(Calendar.MONDAY);
            cal.setMinimalDaysInFirstWeek(4);
            cal.setTimeInMillis(millis);
            ZonedDateTime zdt0 = cal.toZonedDateTime();
            if (cal.getTimeInMillis() != zdt0.toInstant().toEpochMilli() ||
                !cal.equals(GregorianCalendar.from(zdt0))) {
                System.out.println("cal:" + cal);
                System.out.println("zdt:" + zdt0);
                System.out.println("calNew:" + GregorianCalendar.from(zdt0));
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: gcal -> zdt -> gcal");
            }
            inst0 = cal.toInstant();
            if (cal.getTimeInMillis() != inst0.toEpochMilli()) {
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: gcal -> zdt");
            }
            ZonedDateTime zdt = ZonedDateTime.of(ldt_ms, ZoneId.systemDefault());
            GregorianCalendar cal0 = GregorianCalendar.from(zdt);
            if (zdt.toInstant().toEpochMilli() != cal0.getTimeInMillis() ||
                !zdt.equals(GregorianCalendar.from(zdt).toZonedDateTime())) {
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: zdt -> gcal -> zdt");
            }
        }

        ///////////// java.util.TimeZone /////////////////////////
        for (String zidStr : TimeZone.getAvailableIDs()) {
            // TBD: tzdt intergration
            if (zidStr.startsWith("SystemV") ||
                zidStr.contains("Riyadh8") ||
                zidStr.equals("US/Pacific-New") ||
                zidStr.equals("EST") ||
                zidStr.equals("HST") ||
                zidStr.equals("MST")) {
                continue;
            }
            ZoneId zid = ZoneId.of(zidStr, ZoneId.SHORT_IDS);
            if (!zid.equals(TimeZone.getTimeZone(zid).toZoneId())) {
                throw new RuntimeException("FAILED: zid -> tz -> zid :" + zidStr);
            }
            TimeZone tz = TimeZone.getTimeZone(zidStr);
            // no round-trip for alias and "GMT"
            if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId())) &&
                !ZoneId.SHORT_IDS.containsKey(zidStr) &&
                !zidStr.startsWith("GMT")) {
                throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr);
            }
        }
        System.out.println("Passed!");
    }
 
Example 18
Source File: TimeExtensions.java    From gravel with Apache License 2.0 4 votes vote down vote up
public static TimeZone getTimeZoneForOffsetMS_(int ms) {
	String[] availableIDs = TimeZone.getAvailableIDs(ms);
	if (availableIDs.length == 0)
		throw new RuntimeException("No timezone for offset: " + ms);
	return getTimeZoneNamed_(availableIDs[0]);
}
 
Example 19
Source File: Bug6772689.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    TimeZone defaultTimeZone = TimeZone.getDefault();
    int errors = 0;

    Calendar cal = new GregorianCalendar(BEGIN_YEAR, MARCH, 1);
    String[] tzids = TimeZone.getAvailableIDs();
    try {
        for (String id : tzids) {
            TimeZone tz = TimeZone.getTimeZone(id);
            if (!tz.useDaylightTime()) {
                continue;
            }
            TimeZone.setDefault(tz);

          dateloop:
            // Use future dates because sun.util.calendar.ZoneInfo
            // delegates offset transition calculations to a SimpleTimeZone
            // (after 2038 as of JDK7).
            for (int year = BEGIN_YEAR; year < END_YEAR; year++) {
                for (int month = MARCH; month <= NOVEMBER; month++) {
                    cal.set(year, month, 1, 15, 0, 0);
                    int maxDom = cal.getActualMaximum(DAY_OF_MONTH);
                    for (int dom = 1; dom <= maxDom; dom++) {
                        Date date = new Date(year - 1900, month, dom);
                        if (date.getYear()+1900 != year
                            || date.getMonth() != month
                            || date.getDate() != dom) {
                            System.err.printf("%s: got %04d-%02d-%02d, expected %04d-%02d-%02d%n",
                                              id,
                                              date.getYear() + 1900,
                                              date.getMonth() + 1,
                                              date.getDate(),
                                              year,
                                              month + 1,
                                              dom);
                            errors++;
                            break dateloop;
                        }
                    }
                }
            }
        }
    } finally {
        // Restore the default TimeZone.
        TimeZone.setDefault(defaultTimeZone);
    }
    if (errors > 0) {
        throw new RuntimeException("Transition test failed");
    }
}
 
Example 20
Source File: JavatimeTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Throwable {

        int N = 10000;
        long t1970 = new java.util.Date(70, 0, 01).getTime();
        Random r = new Random();
        for (int i = 0; i < N; i++) {
            int days  = r.nextInt(50) * 365 + r.nextInt(365);
            long secs = t1970 + days * 86400 + r.nextInt(86400);
            int nanos = r.nextInt(NANOS_PER_SECOND);
            int nanos_ms = nanos / 1000000 * 1000000; // millis precision
            long millis = secs * 1000 + r.nextInt(1000);
            LocalDateTime ldt = LocalDateTime.ofEpochSecond(secs, nanos, ZoneOffset.UTC);
            LocalDateTime ldt_ms = LocalDateTime.ofEpochSecond(secs, nanos_ms, ZoneOffset.UTC);
            Instant inst = Instant.ofEpochSecond(secs, nanos);
            Instant inst_ms = Instant.ofEpochSecond(secs, nanos_ms);
            ///////////// java.util.Date /////////////////////////
            Date jud = new java.util.Date(millis);
            Instant inst0 = jud.toInstant();
            if (jud.getTime() != inst0.toEpochMilli() ||
                !jud.equals(Date.from(inst0))) {
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: j.u.d -> instant -> j.u.d");
            }
            // roundtrip only with millis precision
            Date jud0 = Date.from(inst_ms);
            if (jud0.getTime() != inst_ms.toEpochMilli() ||
                !inst_ms.equals(jud0.toInstant())) {
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: instant -> j.u.d -> instant");
            }
            //////////// java.util.GregorianCalendar /////////////
            GregorianCalendar cal = new GregorianCalendar();
            // non-roundtrip of tz name between j.u.tz and j.t.zid
            cal.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()));
            cal.setGregorianChange(new java.util.Date(Long.MIN_VALUE));
            cal.setFirstDayOfWeek(Calendar.MONDAY);
            cal.setMinimalDaysInFirstWeek(4);
            cal.setTimeInMillis(millis);
            ZonedDateTime zdt0 = cal.toZonedDateTime();
            if (cal.getTimeInMillis() != zdt0.toInstant().toEpochMilli() ||
                !cal.equals(GregorianCalendar.from(zdt0))) {
                System.out.println("cal:" + cal);
                System.out.println("zdt:" + zdt0);
                System.out.println("calNew:" + GregorianCalendar.from(zdt0));
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: gcal -> zdt -> gcal");
            }
            inst0 = cal.toInstant();
            if (cal.getTimeInMillis() != inst0.toEpochMilli()) {
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: gcal -> zdt");
            }
            ZonedDateTime zdt = ZonedDateTime.of(ldt_ms, ZoneId.systemDefault());
            GregorianCalendar cal0 = GregorianCalendar.from(zdt);
            if (zdt.toInstant().toEpochMilli() != cal0.getTimeInMillis() ||
                !zdt.equals(GregorianCalendar.from(zdt).toZonedDateTime())) {
                System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                throw new RuntimeException("FAILED: zdt -> gcal -> zdt");
            }
        }

        ///////////// java.util.TimeZone /////////////////////////
        for (String zidStr : TimeZone.getAvailableIDs()) {
            // TBD: tzdt intergration
            if (zidStr.startsWith("SystemV") ||
                zidStr.contains("Riyadh8") ||
                zidStr.equals("US/Pacific-New") ||
                zidStr.equals("EST") ||
                zidStr.equals("HST") ||
                zidStr.equals("MST")) {
                continue;
            }
            ZoneId zid = ZoneId.of(zidStr, ZoneId.SHORT_IDS);
            if (!zid.equals(TimeZone.getTimeZone(zid).toZoneId())) {
                throw new RuntimeException("FAILED: zid -> tz -> zid :" + zidStr);
            }
            TimeZone tz = TimeZone.getTimeZone(zidStr);
            // no round-trip for alias and "GMT"
            if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId())) &&
                !ZoneId.SHORT_IDS.containsKey(zidStr) &&
                !zidStr.startsWith("GMT")) {
                throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr);
            }
        }
        System.out.println("Passed!");
    }