本文整理汇总了Java中sun.util.calendar.ZoneInfo.getAliasTable方法的典型用法代码示例。如果您正苦于以下问题:Java ZoneInfo.getAliasTable方法的具体用法?Java ZoneInfo.getAliasTable怎么用?Java ZoneInfo.getAliasTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.util.calendar.ZoneInfo
的用法示例。
在下文中一共展示了ZoneInfo.getAliasTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getZoneStrings
import sun.util.calendar.ZoneInfo; //导入方法依赖的package包/类
String[][] getZoneStrings() {
TimeZoneNamesBundle rb = localeData.getTimeZoneNames(locale);
Set<String> keyset = getZoneIDs();
// Use a LinkedHashSet to preseve the order
Set<String[]> value = new LinkedHashSet<>();
for (String key : keyset) {
value.add(rb.getStringArray(key));
}
// Add aliases data for CLDR
if (type == LocaleProviderAdapter.Type.CLDR) {
// Note: TimeZoneNamesBundle creates a String[] on each getStringArray call.
Map<String, String> aliases = ZoneInfo.getAliasTable();
for (String alias : aliases.keySet()) {
if (!keyset.contains(alias)) {
String tzid = aliases.get(alias);
if (keyset.contains(tzid)) {
String[] val = rb.getStringArray(tzid);
val[0] = alias;
value.add(val);
}
}
}
}
return value.toArray(new String[0][]);
}
示例2: main
import sun.util.calendar.ZoneInfo; //导入方法依赖的package包/类
public static void main(String[] args) {
Map<String,String> map = ZoneInfo.getAliasTable();
String alias = map.get("UTC");
if (!alias.equals("Etc/UTC")) {
throw new RuntimeException("got " + alias + ", expected Etc/UTC");
}
TimeZone GMT = TimeZone.getTimeZone("GMT");
TimeZone UTC = TimeZone.getTimeZone("UTC");
if (!GMT.hasSameRules(UTC)) {
throw new RuntimeException("GMT and UTC have different rules");
}
TimeZone EtcUTC = TimeZone.getTimeZone("Etc/UTC");
if (!UTC.hasSameRules(EtcUTC)) {
throw new RuntimeException("UTC and Etc/UTC have different rules");
}
}