java - 如何用 java 中的新 API 替换 sun.util.caldender.ZoneInfo
问题描述
我在我的一个测试用例中找到了这个 Api Sun.util.calendar.zoneInfo,当我编译它时,我收到警告消息,它说 sun.util.calender.ZoneInfo 是内部专有 API,可能会在未来的版本中删除
@Test @Ignore("This test case was previously ignore, appears incomplete")
public void test_getTimeZoneFromTimeZoneDifferential() throws Exception {
TimeZone customCali = DMessageFactory.getTimeZoneFromTimeZoneDifferential("110");
System.out.println("\ncustomCali: "+customCali+"\n");
String[] ids = TimeZone.getAvailableIDs();
for(int i = 0; i < ids.length; i++) {
TimeZone tz = TimeZone.getTimeZone(ids[i]);
if(tz instanceof sun.util.calendar.ZoneInfo) {
TimeZone realZone = ((sun.util.calendar.ZoneInfo) tz).getLastRuleInstance();
if(realZone == null) {
if(tz.useDaylightTime() == customCali.useDaylightTime() &&
tz.getOffset(0) == customCali.getOffset(0)) {
System.out.println("match2: "+tz+" "+tz.getDisplayName(true, TimeZone.SHORT));
}
//System.out.println("no real zone: "+tz);
continue;
}
if(customCali.hasSameRules(realZone)) {
System.out.println("match: "+realZone.getDisplayName(true, TimeZone.SHORT));
}
else if(realZone.getOffset(0) == customCali.getOffset(0)) {
//System.out.println("semi-match: "+tz);
}
else {
//System.out.println("NO-match: "+tz);
}
} else {
//System.out.println("no-match: "+tz);
}
}
我真的需要替换这个 sun.util.calendar.ZoneInfo 并添加另一个 API 而不会破坏它的功能,请帮我解决这个问题。
解决方案
推荐阅读
- class - 我正在尝试清除元素键上的错误对象但没有成功
- javascript - react-router-dom 页面不会切换?
- angular - Observable 不订阅延迟加载的模块
- python - 我的带有身份内核的 PyTorch Conv1d 不会产生与输入相同的输出
- php - 有没有办法从使用循环创建的表中设置 $_SESSION 变量
- javascript - For with Return in Javascript
- azure - Azure 文件共享与 AAD DS 的集成
- javascript - 将数据更新/插入 mysql 时面临 mysqli_query 问题
- bash - Shell 脚本错误:“回显:写入错误:超出磁盘配额”
- firebase - Firebase - 保留率(队列)