本文整理汇总了Java中com.ibm.icu.util.TimeZone.getWindowsID方法的典型用法代码示例。如果您正苦于以下问题:Java TimeZone.getWindowsID方法的具体用法?Java TimeZone.getWindowsID怎么用?Java TimeZone.getWindowsID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.util.TimeZone
的用法示例。
在下文中一共展示了TimeZone.getWindowsID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterPropertiesSet
import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
boolean timeZoneSet = false;
TimeZone jvmTimeZone = TimeZone.getDefault();
if(jvmTimeZone != null){
String windowsID = TimeZone.getWindowsID(jvmTimeZone.getID());
if(StringUtils.isNotBlank(windowsID)){
log.info("windows time zone context has been set to '"+windowsID+"'. All dates and times sent to (or recieved from) EWS must use this timezone information.");
this.windowsTimeZoneID = windowsID;
timeZoneSet=true;
}else{
log.warn("No windows time zone mapping for "+jvmTimeZone.getID());
}
}else{
log.warn("jvm timezone is not set, this should never happen");
}
if(!timeZoneSet){
log.warn("Failed to identify a matching time zone scheme. Falling back to UTC.");
TimeZone fallbackTimeZone = TimeZone.getTimeZone(FALLBACK_TIMEZONE_ID);
TimeZone.setDefault(fallbackTimeZone);
this.windowsTimeZoneID = FALLBACK_TIMEZONE_ID;
}
}
示例2: getTimeZoneIds
import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
* Executes a {@link GetServerTimeZones} request, retrieving all {@link TimeZoneDefinitionType}s from Exchange.
* Attempts to map each {@link TimeZoneDefinitionType} to an {@link TimeZone} and logs the result.
*/
@Test
public void getTimeZoneIds(){
int validTimeZoneCount = 0;
List<TimeZoneDefinitionType> zones = exchangeCalendarDataDao.getServerTimeZones(null, false);
log.info("Found "+zones.size() +" exchange time zones.");
for(TimeZoneDefinitionType zone: zones){
String sysTimeZoneID = TimeZone.getIDForWindowsID(zone.getId(), "US");
if(StringUtils.isNotBlank(sysTimeZoneID)){
log.info(zone.getId() +" mapped to "+ sysTimeZoneID);
String windowsID = TimeZone.getWindowsID(sysTimeZoneID);
assertEquals(zone.getId(), windowsID);
validTimeZoneCount++;
}else{
log.warn("no mapping for windowsID="+zone.getId());
}
}
log.info("Succesfully mapped "+validTimeZoneCount+"/"+zones.size()+" WindowsTimeZones");
}
示例3: isTimeZoneValid
import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
public boolean isTimeZoneValid(){
boolean tzValid = false;
TimeZone tzDefault = TimeZone.getDefault();
if(null != tzDefault && StringUtils.isNotBlank(tzDefault.getID())){
String windowsID = TimeZone.getWindowsID(tzDefault.getID());
tzValid = this.windowsTimeZoneID.equals(windowsID);
}
return tzValid;
}
示例4: getWindowsTimeZoneIDForSysTimeZoneIDs
import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
@Test
public void getWindowsTimeZoneIDForSysTimeZoneIDs(){
int validZonesCount = 0;
String[] availableIDs = TimeZone.getAvailableIDs();
for(String sysTimeZoneID : availableIDs){
String windowsID = TimeZone.getWindowsID(sysTimeZoneID);
if(null != windowsID){
log.info(sysTimeZoneID+" maps to "+windowsID);
validZonesCount++;
}else{
log.warn("NO MAPPING FOR "+sysTimeZoneID);
}
}
log.info(validZonesCount +"/"+availableIDs.length +" system time zone ids can be mapped to a windows time zone id");
}