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


Java TimeZone.getTimeZone方法代码示例

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


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

示例1: getObjectToFormat

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * A method to retrieve a formattable object for this object.
 * It is important to set the GMT TimeZone to avoid conversions related to TimeZone.
 */
@Override
public Calendar getObjectToFormat() {
  if (isNull()) {
    return null;
  }

  // Set GMT TimeZone.
  Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
  // Set to some predefined default. Don't change this default.
  cal.set(Calendar.YEAR, 1899);
  cal.set(Calendar.MONTH, Calendar.DECEMBER);
  cal.set(Calendar.DAY_OF_MONTH, 30);
  // Set the TimeOfDay based on this TimeOfDayValue.
  cal.set(Calendar.HOUR_OF_DAY, hours);
  cal.set(Calendar.MINUTE, minutes);
  cal.set(Calendar.SECOND, seconds);
  cal.set(Calendar.MILLISECOND, milliseconds);

  return cal;
}
 
开发者ID:dzxdzx1987,项目名称:GoogleCharts,代码行数:25,代码来源:TimeOfDayValue.java

示例2: evaluate

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * Executes this scalar function on the given values. Returns values[0] - values[1] expressed
 * as a number value denoting the number of days from one date to the other. Both values can be
 * of type date or date-time. Only the date parts of date-time values are used in the calculation.
 * Thus the returned number is always an integer.
 * The method does not validate the parameters, the user must check the
 * parameters before calling this method.
 *
 * @param values A list of values on which the scalar function will be performed.
 *
 * @return Value holding the difference, in whole days, between the two given Date/DateTime
 *     values, or a null value (of type number) if one of the values is null.
 */
public Value evaluate(List<Value> values) {
  Value firstValue = values.get(0);
  Value secondValue = values.get(1);

  // If one of the values is null, return a null number value.
  if (firstValue.isNull() || secondValue.isNull()) {
    return NumberValue.getNullValue();
  }
  Date firstDate = getDateFromValue(firstValue);
  Date secondDate = getDateFromValue(secondValue);

  GregorianCalendar calendar =
      new GregorianCalendar(TimeZone.getTimeZone("GMT"));
  calendar.setTime(secondDate);
  return new NumberValue(calendar.fieldDifference(firstDate, Calendar.DATE));
}
 
开发者ID:dzxdzx1987,项目名称:GoogleCharts,代码行数:30,代码来源:DateDiff.java

示例3: testTocFind

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
public void testTocFind() throws Exception
{
	ITreeNode tree = createTocNormal( );
	TOCView view = new TOCView( tree, null, ULocale.ENGLISH, TimeZone
			.getTimeZone( "GMT+08:00" ), "html" );
	
	checkTocNode(view, "/", null, 3);
	checkTocNode(view, "__TOC_0", "report header", 0);
	checkTocNode(view, "__TOC_1", "table", 2);
	checkTocNode(view, "__TOC_1_0", "group 1", 2);
	checkTocNode(view, "__TOC_1_0_0", "detail 1", 0);
	checkTocNode(view, "__TOC_1_0_1", "detail 2", 0);
	checkTocNode(view, "__TOC_1_1", "group 2", 2);
	checkTocNode(view, "__TOC_1_1_0", "detail 3", 0);
	checkTocNode(view, "__TOC_1_1_1", "detail 4", 0);
	checkTocNode(view, "__TOC_2_0", "chart 1", 0);
	checkTocNode(view, "__TOC_2_1", "chart 2", 0);
	assertTrue( view.findTOC( "__TOC_0_0" ) == null );
	assertTrue( view.findTOC( "__TOC_1_1_2" ) == null );
	assertTrue( view.findTOC( "__TOC_1_1_1_0" ) == null );
	assertTrue( view.findTOC( "__TOC_3" ) == null );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:23,代码来源:TOCViewTest.java

示例4: 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

示例5: getTimeZoneForOffset

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * Creates an instance of TimeZone for the given offset
 * @param offset the offset
 * @return A TimeZone with the given offset
 */
private TimeZone getTimeZoneForOffset(int offset) {
    if (offset == 0) {
        // when offset is 0, we should use "Etc/GMT"
        return TimeZone.getTimeZone(TZID_GMT);
    }
    return ZoneMeta.getCustomTimeZone(offset);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:13,代码来源:TimeZoneFormat.java

示例6: getEquivalentTimeZoneId

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * Return equivalent Olson timezone id that corresponds to given 
 * VTIMEZONE definition
 * @param vtz VTIMEZONE
 * @return equivalent timezone id (null if no equivalent timezone found)
 */
public static String getEquivalentTimeZoneId(VTimeZone vtz) {
    
    com.ibm.icu.util.VTimeZone icuvtz = com.ibm.icu.util.VTimeZone.create(new StringReader(vtz.toString()));
    for(String id: allTimezoneIds) {
        TimeZone tz = TimeZone.getTimeZone(id);
        if(icuvtz.hasSameRules(tz)) {
            return id;
        }
    }
    
    return null;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:19,代码来源:TimeZoneUtils.java

示例7: testTocViewNormal

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
public void testTocViewNormal( ) throws EngineException, IOException
{
	ITreeNode tree = createTocNormal( );
	System.out.println( toString( tree ) );
	TOCView view = new TOCView( tree, null, ULocale.ENGLISH, TimeZone
			.getTimeZone( "GMT+08:00" ), "html" );
	String output = toString( view.getRoot( ) );
	System.out.println( output );
	assertEquals( TOC_NORMAL_GOLDEN.replaceAll( "\\s", "" ), output
			.replaceAll( "\\s", "" ) );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:12,代码来源:TOCViewTest.java

示例8: testTocViewWithFormat

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
public void testTocViewWithFormat( ) throws EngineException, IOException
{
	ITreeNode tree = createTocWithFormat( );
	System.out.println( toString( tree ) );
	TOCView view = new TOCView( tree, null, ULocale.ENGLISH, TimeZone
			.getTimeZone( "GMT+08:00" ), "html" );
	String output = toString( view.getRoot( ) );
	System.out.println( output );
	assertEquals( TOC_WITH_FORMAT_GOLDEN.replaceAll( "\\s", "" ), output
			.replaceAll( "\\s", "" ) );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:12,代码来源:TOCViewTest.java

示例9: testTocViewWithEmptyGorup

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
public void testTocViewWithEmptyGorup( ) throws EngineException,
		IOException
{
	ITreeNode tree = createTocWithEmptyGroup( );
	System.out.println( toString( tree ) );
	TOCView view = new TOCView( tree, null, ULocale.ENGLISH, TimeZone
			.getTimeZone( "GMT+08:00" ), "html" );
	String output = toString( view.getRoot( ) );
	System.out.println( output );
	assertEquals( TOC_WITH_EMPTY_GROUP_GOLDEN.replaceAll( "\\s", "" ),
			output.replaceAll( "\\s", "" ) );

}
 
开发者ID:eclipse,项目名称:birt,代码行数:14,代码来源:TOCViewTest.java

示例10: updateTimeForTimeZone

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * when the TimeZone is changed ,update the time
 * 
 * @param oldID
 * @param newID
 * @return true
 */
public boolean updateTimeForTimeZone( String oldID, String newID )
{

	TimeZone oldZone = TimeZone.getTimeZone( oldID );
	TimeZone newZone = TimeZone.getTimeZone( newID );

	int oldOff = oldZone.getRawOffset( );
	int newOff = newZone.getRawOffset( );

	time = time + ( newOff - oldOff );
	String text = getShowText( getFormatType( ) );
	setText( text );
	return true;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:22,代码来源:TimeLabel.java

示例11: updateTimeForTimeZone

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
public boolean updateTimeForTimeZone( String oldID, String newID )
{
	long time = cale.getTimeInMillis( );
	TimeZone oldZone = TimeZone.getTimeZone( oldID );
	TimeZone newZone = TimeZone.getTimeZone( newID );

	int oldOff = oldZone.getRawOffset( );
	int newOff = newZone.getRawOffset( );

	time = time + ( newOff - oldOff );
	cale.setTimeInMillis( time );

	return true;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:15,代码来源:TimeOptionDialog.java

示例12: testTimeZone

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
@Test
   public void testTimeZone()
{
	String result = null;
	DateFormatter df = null;

	Calendar dateCal = Calendar.getInstance( );
	dateCal.setTimeZone(java.util.TimeZone.getTimeZone("PST"));
	dateCal.set( 1998, 8, 13, 5, 1, 44 );
	Date dateTime = dateCal.getTime( );
	java.sql.Time sqlTime = new java.sql.Time( dateTime.getTime( ) );

	String utcDate = "13 Sep 1998 12:01";
	String utcTime = "12:01:44";
	TimeZone UTCTimeZone = TimeZone.getTimeZone( "UTC" );
	df = new DateFormatter( ULocale.UK, UTCTimeZone );
	result = df.format( dateTime );
	assertTrue( utcDate.equalsIgnoreCase( result ) );
	result = df.format( sqlTime );
	assertTrue( utcTime.equalsIgnoreCase( result ) );

	String japanDate = "1998/09/13 21:01";
	String japanTime = "21:01:44";
	TimeZone japanTimeZone = TimeZone.getTimeZone( "Japan" );
	df = new DateFormatter( ULocale.JAPAN, japanTimeZone );
	result = df.format( dateTime );
	assertTrue( japanDate.equalsIgnoreCase( result ) );
	result = df.format( sqlTime );
	assertTrue( japanTime.equalsIgnoreCase( result ) );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:31,代码来源:DateFormatterTest.java

示例13: 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

示例14: 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

示例15: initCommonOptions

import com.ibm.icu.util.TimeZone; //导入方法依赖的package包/类
/**
 * Initializes the common options based on the data extraction option. If
 * the passed option doesn't contain common options, use default values.
 * 
 * @param context
 * @param options
 *            options
 */
private void initCommonOptions( IReportContext context,
		IDataExtractionOption options )
{
	String dateFormat = null;
	ICommonDataExtractionOption commonOptions;
	if ( options instanceof ICommonDataExtractionOption )
	{
		commonOptions = (ICommonDataExtractionOption) options;
	}
	else
	{
		commonOptions = new CommonDataExtractionOption( options.getOptions( ) );
	}

	this.isLocaleNeutral = commonOptions.isLocaleNeutralFormat( );
	this.localeNeutralFlags = commonOptions.getLocaleNeutralFlags( );

	dateFormat = commonOptions.getDateFormat( );
	// get locale info
	Locale aLocale = null;
	if ( commonOptions.getLocale( ) != null )
	{
		aLocale = commonOptions.getLocale( );
	}
	else if ( context != null )
	{
		aLocale = context.getLocale( );
	}
	if ( aLocale == null )
	{
		this.locale = ULocale.forLocale( Locale.getDefault( ) );
	}
	else
	{
		this.locale = ULocale.forLocale( aLocale );
	}

	java.util.TimeZone javaTimeZone = commonOptions.getTimeZone( );
	if ( javaTimeZone != null )
	{
		// convert java time zone to ICU time zone
		this.timeZone = TimeZone.getTimeZone( javaTimeZone.getID( ) );
	}
	else if ( context != null )
	{
		timeZone = context.getTimeZone( );
	}
	else
	{
		timeZone = TimeZone.getDefault( );
	}

	if ( !isLocaleNeutral )
	{
		dateFormatter = createDateFormatter( dateFormat,
				this.locale,
				this.timeZone );
	}
	formatterMap = commonOptions.getFormatter( );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:69,代码来源:CommonDataExtractionImpl.java


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