【发布时间】:2019-08-04 13:23:37
【问题描述】:
我在我的一个测试用例中发现了这个 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 而不会破坏它的功能,请帮我解决这个问题。
【问题讨论】:
标签: java api junit timezone internals