当前位置: 首页>>代码示例>>Java>>正文


Java TimeZone.setDefault方法代码示例

本文整理汇总了Java中com.ibm.icu.util.TimeZone.setDefault方法的典型用法代码示例。如果您正苦于以下问题:Java TimeZone.setDefault方法的具体用法?Java TimeZone.setDefault怎么用?Java TimeZone.setDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ibm.icu.util.TimeZone的用法示例。


在下文中一共展示了TimeZone.setDefault方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apiSetUp

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
@Before
   public void apiSetUp() throws Exception
{

	
	defaultTimeZone = TimeZone.getDefault( );
	TimeZone.setDefault( TimeZone.getTimeZone( "GMT" ) );
	DataEngineContext context = DataEngineContext.newInstance( DataEngineContext.DIRECT_PRESENTATION,
			this.scriptContext,
			null,
			null,
			null );
	context.setTmpdir( this.getTempDir( ) );
	PlatformConfig cfg = new PlatformConfig();
	cfg.setTempDir(this.getTempDir( ));
	dataEngine = DataEngine.newDataEngine( cfg, context );
	prepareDataSource( );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:19,代码来源:APITestCase.java

示例2: viewing2TearDown

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
@After
   public void viewing2TearDown() throws Exception
{
	if( myPreDataEngine != null )
	{
		myPreDataEngine.shutdown( );
		myPreDataEngine.clearCache( dataSource, dataSet );
		myPreDataEngine = null;
	}
	if( myPreDataEngine2 != null )
	{
		myPreDataEngine2.shutdown( );
		myPreDataEngine2.clearCache( dataSource, dataSet );
		myPreDataEngine2 = null;
	}
	TimeZone.setDefault( this.currentTimeZone  );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:18,代码来源:ViewingTest2.java

示例3: 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;
	}
}
 
开发者ID:Bedework,项目名称:exchange-ws-client,代码行数:25,代码来源:RequestServerTimeZoneInterceptor.java

示例4: columnBindingSetUp

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * 
 */
@Before
   public void columnBindingSetUp() throws Exception
{

	
	TimeZone.setDefault( TimeZone.getTimeZone("GMT+0")  );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:11,代码来源:ColumnBindingTest.java

示例5: apiTearDown

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
@After
   public void apiTearDown() throws Exception
{
	dataEngine.shutdown( );
	closeDataSource( );
	
	TimeZone.setDefault( defaultTimeZone );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:9,代码来源:APITestCase.java

示例6: unmappableTimeZoneTest

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * A timezone with no Windows equivalant is set before initalization.
 *  This causes {@link RequestServerTimeZoneInterceptor} to set the default {@link TimeZone} to UTC
 *  AND sets {@link RequestServerTimeZoneInterceptor}.windowsID to UTC
 */
@Test
public void unmappableTimeZoneTest(){
	
	TimeZone badTimeZone = TimeZone.getTimeZone(badTimeZoneID);
	TimeZone.setDefault(badTimeZone);
	assertEquals(TimeZone.getDefault(), badTimeZone);
	
	ApplicationContext context = new ClassPathXmlApplicationContext("classpath:test-contexts/exchangeContext.xml");
	RequestServerTimeZoneInterceptor timeZoneInterceptor = context.getBean(RequestServerTimeZoneInterceptor.class);
	
	assertEquals(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID, TimeZone.getDefault().getID());
	assertEquals(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID, timeZoneInterceptor.getWindowsTimeZoneID());
}
 
开发者ID:Bedework,项目名称:exchange-ws-client,代码行数:19,代码来源:TimeZoneIntegrationTest.java

示例7: badTimeZoneContextTest

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
@Test
public void badTimeZoneContextTest() throws DatatypeConfigurationException{
	
	TimeZone badTimeZone = TimeZone.getTimeZone(badTimeZoneID);
	TimeZone.setDefault(badTimeZone);
	assertEquals(TimeZone.getDefault(), badTimeZone);
	
	ApplicationContext context = new ClassPathXmlApplicationContext("classpath:test-contexts/exchangeContext.xml");
	RequestServerTimeZoneInterceptor timeZoneInterceptor = context.getBean(RequestServerTimeZoneInterceptor.class);
	
	assertEquals(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID, TimeZone.getDefault().getID());
	assertEquals(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID, timeZoneInterceptor.getWindowsTimeZoneID());
	
	//time zone currently set to utc, create a date using default time zone
	XMLGregorianCalendar now = DateHelp.getXMLGregorianCalendarNow();
	
	//change the default time zone, so the RequestServerTimeZoneInterceptor is out of sync with default time zone.
	TimeZone.setDefault(badTimeZone);

	ExchangeWebServices ews = context.getBean(ExchangeWebServices.class);
	BaseExchangeCalendarDataDao exchangeCalendarDao = context.getBean(BaseExchangeCalendarDataDao.class);
	exchangeCalendarDao.setWebServices(ews);
	
	//attempt an ews call, which should fail...
	try{
		exchangeCalendarDao.getCalendarFolderMap("[email protected]");
		fail("exchangeCalendarDao should have thrown exception...");
	}catch(ExchangeWebServicesRuntimeException e){}
	
	//change timezone back and call should now succed
	TimeZone.setDefault(TimeZone.getTimeZone(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID));
	exchangeCalendarDao.getCalendarFolderMap(upn);
}
 
开发者ID:Bedework,项目名称:exchange-ws-client,代码行数:34,代码来源:TimeZoneIntegrationTest.java

示例8: setUp

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * @see com.google.gwt.user.client.rpc.RpcTestBase#setUp()
 */
@Override
protected void setUp() throws Exception {
	super.setUp();
	TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
 
开发者ID:jcricket,项目名称:gwt-syncproxy,代码行数:9,代码来源:CollectionsTest.java

示例9: columnBindingTearDown

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * @throws Exception 
 * 
 */
@After
   public void columnBindingTearDown() throws Exception
{
	TimeZone.setDefault( this.currentTimeZone  );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:10,代码来源:ColumnBindingTest.java

示例10: viewing2SetUp

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
@Before
   public void viewing2SetUp() throws Exception
{

	
	this.notIncludeAggr = false;
	
	this.add_subquery_on_query = false;
	this.USE_ROW_IN_AGGREGATION = false;

	this.GEN_queryResultID = null;
	this.UPDATE_queryResultID = null;
	this.USE_DATE_IN_COLUMNBINDING = true;
	
	this.GEN_add_subquery = false;
	this.GEN_add_sort = true;
	// dataSetRow.AMOUNT>50
	this.GEN_add_filter = false;
	// dataSetRow.COUNTRY
	this.GEN_add_group = false;
	// print information
	this.GEN_print = false;
	this.GEN_USE_RUNNING_AGGR = false;
	this.GEN_use_invalid_column = false;
	
	// row.AMOUNT_1>200 -> dataSetRow.AMOUNT>200
	this.UPDATE_add_filter = -1;
	// row.AMOUNT_1 ASC
	this.UPDATE_add_sort = false;
	// group on row.AMOUNT_1
	this.UPDATE_add_diff_group = false;
	// dataSetRow.COUNTRY
	this.UPDATE_add_same_group = false;
	// dataSetRow.COUNTRY
	this.UPDATE_add_subquery = 0;
	
	this.USE_DATE_IN_SUBQUERY = false;
	// 0: row.AMOUNT_1>200
	// 1: row.AMOUNT_1>50 && row.AMOUNT_1<7000
	// 2: row.AMOUNT_1>50 && row.AMOUNT_1<700
	this.PRE_add_filter = -1;
	// row.AMOUNT_1 ASC
	this.PRE_add_sort = false;
	
	this.PRE_execute_query = false;
	this.PRE_print_groupinfo = false;
	this.PRE_use_skipto = false;
	this.PRE_use_skipto_num = -1;
	this.PRE_add_group = -1;
	this.PRE_basedon_genfilter = false;
	
	this.GEN_filterDefn = new ArrayList( );
	this.UPDATE_filterDefn = new ArrayList( );
	
	this.TEST_ISEMPTY = false;
	
	TimeZone.setDefault( TimeZone.getTimeZone("GMT+0")  );
	
}
 
开发者ID:eclipse,项目名称:birt,代码行数:60,代码来源:ViewingTest2.java

示例11: createGetDeleteCalendarItem

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
@Test
public void createGetDeleteCalendarItem() throws DatatypeConfigurationException{
	
	TimeZone utcTimeZone = TimeZone.getTimeZone(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID);
	TimeZone.setDefault(utcTimeZone);
	
	ApplicationContext context = new ClassPathXmlApplicationContext("classpath:test-contexts/exchangeContext.xml");
	RequestServerTimeZoneInterceptor timeZoneInterceptor = context.getBean(RequestServerTimeZoneInterceptor.class);
	ExchangeWebServices ews = context.getBean(ExchangeWebServices.class);
	BaseExchangeCalendarDataDao exchangeCalendarDao = context.getBean(BaseExchangeCalendarDataDao.class);
	exchangeCalendarDao.setWebServices(ews);
	
	assertEquals(TimeZone.getDefault(), utcTimeZone);
	
	//XMLGregorianCalendar is sortof backed by a gregorian calendar, date/times should reflect default jvm timezone
	XMLGregorianCalendar xmlStart = DateHelp.getXMLGregorianCalendarNow();
	
	CalendarItemType calendarItem = new CalendarItemType();
	calendarItem.setStart(xmlStart);

	ItemIdType itemId = exchangeCalendarDao.createCalendarItem(upn, calendarItem);
	assertNotNull(itemId);
	Set<ItemIdType> itemIds = Collections.singleton(itemId);
	Set<CalendarItemType> calendarItems = exchangeCalendarDao.getCalendarItems(upn, itemIds);
	assertNotNull(calendarItems);
	CalendarItemType createdCalendarItem = DataAccessUtils.singleResult(calendarItems);
	assertNotNull(createdCalendarItem);
	XMLGregorianCalendar createdCalendarItemStart = createdCalendarItem.getStart();
	
	assertNotNull(createdCalendarItemStart);
	assertEquals(xmlStart.getTimezone(), createdCalendarItemStart.getTimezone());

	//nope! tzDisplayName = createdCalendarItem.getTimeZone()
	//assertEquals(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID, createdCalendarItem.getTimeZone());
	
	assertEquals(xmlStart.getEon(), createdCalendarItemStart.getEon());
	assertEquals(xmlStart.getEonAndYear(), createdCalendarItemStart.getEonAndYear());
	assertEquals(xmlStart.getYear(), createdCalendarItemStart.getYear());
	assertEquals(xmlStart.getMonth(), createdCalendarItemStart.getMonth());
	assertEquals(xmlStart.getDay(), createdCalendarItemStart.getDay());
	assertEquals(xmlStart.getHour(), createdCalendarItemStart.getHour());	
	assertEquals(xmlStart.getMinute(), createdCalendarItemStart.getMinute());	
	assertEquals(xmlStart.getSecond(), createdCalendarItemStart.getSecond());	
	
	//nope!  always seems to be a slight variation
	//assertEquals(xmlStart.toGregorianCalendar().getTimeInMillis(), createdCalendarItemStart.toGregorianCalendar().getTimeInMillis());
	//assertEquals(xmlStart.getMillisecond(), createdCalendarItemStart.getMillisecond());	
	//assertEquals(xmlStart.getFractionalSecond(), createdCalendarItemStart.getFractionalSecond());
	
	assertTrue(DateHelp.withinOneSecond(xmlStart, createdCalendarItemStart));
	
	assertTrue(exchangeCalendarDao.deleteCalendarItems(upn, itemIds));
}
 
开发者ID:Bedework,项目名称:exchange-ws-client,代码行数:54,代码来源:TimeZoneIntegrationTest.java


注:本文中的com.ibm.icu.util.TimeZone.setDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。