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


Java TimeZone.getAvailableIDs方法代码示例

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


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

示例1: setTimeZone

import java.util.TimeZone; //导入方法依赖的package包/类
protected void setTimeZone(char timeZoneFlag, char t0, char t1, char t3, char t4) {
    int timeZoneOffset = ((t0 - '0') * 10 + (t1 - '0')) * 3600 * 1000;

    timeZoneOffset += ((t3 - '0') * 10 + (t4 - '0')) * 60 * 1000;

    if (timeZoneFlag == '-') {
        timeZoneOffset = -timeZoneOffset;
    }

    if (calendar.getTimeZone().getRawOffset() != timeZoneOffset) {
        String[] timeZoneIDs = TimeZone.getAvailableIDs(timeZoneOffset);
        if (timeZoneIDs.length > 0) {
            TimeZone timeZone = TimeZone.getTimeZone(timeZoneIDs[0]);
            calendar.setTimeZone(timeZone);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:JSONScanner.java

示例2: getDateValue

import java.util.TimeZone; //导入方法依赖的package包/类
private Date getDateValue(int year, int month, int day, int hours, int minutes, int sec, int msec, int offsetInMinutes)
{
    // minute in millis
    int millisInMinute = 1000 * 60;

    GregorianCalendar gc = new GregorianCalendar();

    // set correct offset
    String[] tzArray = TimeZone.getAvailableIDs(millisInMinute * offsetInMinutes);
    if (tzArray.length > 0)
    {
        gc.setTimeZone(TimeZone.getTimeZone(tzArray[0]));
    }

    // set date
    gc.set(GregorianCalendar.YEAR, year);
    gc.set(GregorianCalendar.MONTH, month - 1);
    gc.set(GregorianCalendar.DAY_OF_MONTH, day);
    gc.set(GregorianCalendar.HOUR_OF_DAY, hours);
    gc.set(GregorianCalendar.MINUTE, minutes);
    gc.set(GregorianCalendar.SECOND, sec);
    gc.set(GregorianCalendar.MILLISECOND, msec);

    return gc.getTime();
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:26,代码来源:ISO8601DateFormatTest.java

示例3: loadTimeZoneMappings

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * Loads a properties file that contains all kinds of time zone mappings.
 * 
 * @param exceptionInterceptor
 * @throws SQLException
 */
private static void loadTimeZoneMappings(ExceptionInterceptor exceptionInterceptor) throws SQLException {
    timeZoneMappings = new Properties();
    try {
        timeZoneMappings.load(TimeUtil.class.getResourceAsStream(TIME_ZONE_MAPPINGS_RESOURCE));
    } catch (IOException e) {
        throw SQLError.createSQLException(Messages.getString("TimeUtil.LoadTimeZoneMappingError"), SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE,
                exceptionInterceptor);
    }
    // bridge all Time Zone ids known by Java
    for (String tz : TimeZone.getAvailableIDs()) {
        if (!timeZoneMappings.containsKey(tz)) {
            timeZoneMappings.put(tz, tz);
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:22,代码来源:TimeUtil.java

示例4: testDateTimezones

import java.util.TimeZone; //导入方法依赖的package包/类
public void testDateTimezones() throws IOException{
    
    final int [] offsets = { -14400000, -4200000, 14400000, 4300000 };
    for(int offset : offsets) {
        for(String tzId : TimeZone.getAvailableIDs(offset)) {
            final TimeZone tz =TimeZone.getTimeZone(tzId);
            final Calendar cal = Calendar.getInstance(tz);
            DateFormat fmt = new SimpleDateFormat(ECMA_FORMAT, Locale.ENGLISH);
            fmt.setTimeZone(tz);
            final String ecmaNow = fmt.format(cal.getTime());
            final String isoNow=ISO8601.format(cal);
            
            final Calendar cal2= Calendar.getInstance(tz);
            final String ecmaNow2 = fmt.format(cal2.getTime());
            final String isoNow2=ISO8601.format(cal2);   
                
            doDateTest(ecmaNow, isoNow, ecmaNow2, isoNow2);
        }
    }
    
    
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:23,代码来源:SlingDateValuesTest.java

示例5: Test4031502

import java.util.TimeZone; //导入方法依赖的package包/类
public void Test4031502() {
    // This bug actually occurs on Windows NT as well, and doesn't
    // require the host zone to be set; it can be set in Java.
    String[] ids = TimeZone.getAvailableIDs();
    boolean bad = false;
    for (int i = 0; i < ids.length; ++i) {
        TimeZone zone = TimeZone.getTimeZone(ids[i]);
        GregorianCalendar cal = new GregorianCalendar(zone);
        cal.clear();
        cal.set(1900, 15, 5, 5, 8, 13);
        if (cal.get(HOUR) != 5) {
            logln(zone.getID() + " "
                    + //zone.useDaylightTime() + " "
                    + cal.get(DST_OFFSET) / (60 * 60 * 1000) + " "
                    + zone.getRawOffset() / (60 * 60 * 1000)
                    + ": HOUR = " + cal.get(HOUR));
            bad = true;
        }
    }
    if (bad) {
        errln("TimeZone problems with GC");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:CalendarRegression.java

示例6: getTimeZoneIds

import java.util.TimeZone; //导入方法依赖的package包/类
public static List<String> getTimeZoneIds()
{
	List<String> zoneIds = new ArrayList<String>();

	// remove zoneIds that are <= 3 chars long, otherwise you get all sorts
	// of undesirable rubbish
	// this seems to be the best way to weed them out.
	for( String zoneId : TimeZone.getAvailableIDs() )
	{
		if( zoneId.length() > 3 )
		{
			zoneIds.add(zoneId);
		}
	}

	return zoneIds;
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:DateHelper.java

示例7: loadTimeZoneMappings

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * Loads a properties file that contains all kinds of time zone mappings.
 * 
 * @param exceptionInterceptor
 * @throws SQLException
 */
private static void loadTimeZoneMappings(ExceptionInterceptor exceptionInterceptor) throws SQLException {
    timeZoneMappings = new Properties();
    try {
        timeZoneMappings.load(TimeZone.class.getResourceAsStream(TIME_ZONE_MAPPINGS_RESOURCE));
    } catch (IOException e) {
        throw SQLError.createSQLException(Messages.getString("TimeUtil.LoadTimeZoneMappingError"), SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE,
                exceptionInterceptor);
    }
    // bridge all Time Zone ids known by Java
    for (String tz : TimeZone.getAvailableIDs()) {
        if (!timeZoneMappings.containsKey(tz)) {
            timeZoneMappings.put(tz, tz);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:TimeUtil.java

示例8: unspecified

import java.util.TimeZone; //导入方法依赖的package包/类
/**
    * Displays list of all JRE available timezones.
    */
   @Override
   public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {

timezoneService = AdminServiceProxy.getTimezoneService(getServlet().getServletContext());
List<Timezone> defaultTimezones = timezoneService.getDefaultTimezones();

ArrayList<TimezoneDTO> timezoneDtos = new ArrayList<TimezoneDTO>();
for (String availableTimezoneId : TimeZone.getAvailableIDs()) {
    boolean isSelected = defaultTimezones.contains(new Timezone(availableTimezoneId));
    TimeZone timeZone = TimeZone.getTimeZone(availableTimezoneId);
    TimezoneDTO timezoneDto = TimezoneDTO.createTimezoneDTO(timeZone, isSelected);
    timezoneDtos.add(timezoneDto);
}

request.setAttribute("timezoneDtos", timezoneDtos);
request.setAttribute("serverTimezone", timezoneService.getServerTimezone().getTimezoneId());

return mapping.findForward(FORWARD_TIMEZONE_MANAGEMENT);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:TimezoneManagementAction.java

示例9: printTimeZoneAvailableIDs

import java.util.TimeZone; //导入方法依赖的package包/类
public static void printTimeZoneAvailableIDs() {
	String[] ids = TimeZone.getAvailableIDs();
	TimeZone timeZone;
	if (LOG.isDebugEnabled()) {
		LOG.debug(TimeZone.getDefault().toString());
	}

	for (int i = 0; i < ids.length; i++) {
		System.out.println("");
		timeZone = TimeZone.getTimeZone(ids[i]);
		if (LOG.isDebugEnabled()) {
			LOG.debug("ids[" + i + "]=" + ids[i] + " timeZone=" + timeZone);
			LOG.debug(timeZone.getDisplayName() + "	" + timeZone.getDisplayName(true, 1, Locale.US));
		}
		if (timeZone.equals(TimeZone.getDefault())) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("printTimeZoneAvailableIDs ****************************i=" + i);
			}
		}
	}
}
 
开发者ID:fier-liu,项目名称:FCat,代码行数:22,代码来源:DateUtil.java

示例10: shouldPrintTimeZone

import java.util.TimeZone; //导入方法依赖的package包/类
@Test
public void shouldPrintTimeZone() {

    for (int x = 0; x < TimeZone.getAvailableIDs().length; x++) {
        System.out.println(TimeZone.getAvailableIDs()[x]);
    }

}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:9,代码来源:DateUtilsTest.java

示例11: getAvailable

import java.util.TimeZone; //导入方法依赖的package包/类
public static List<TimeZoneWrapper> getAvailable ()
{
    final String[] tz = TimeZone.getAvailableIDs ();
    final List<TimeZoneWrapper> result = new ArrayList<> ( tz.length );

    for ( int i = 0; i < tz.length; i++ )
    {
        result.add ( new TimeZoneWrapper ( TimeZone.getTimeZone ( tz[i] ) ) );
    }

    return result;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:TimeZoneWrapper.java

示例12: getTimeZoneNamesKVReversed

import java.util.TimeZone; //导入方法依赖的package包/类
public static Map<String, String> getTimeZoneNamesKVReversed() {
  String[] timezones = TimeZone.getAvailableIDs();
  Map<String, String> timezoneMap = new HashMap<String, String>();
  for (int i = 0; i < timezones.length; i++) {
    if (timezones[i].matches(TIMEZONE_ID_PREFIXES)) {
      timezoneMap.put(timezones[i], TimeZone.getTimeZone(timezones[i]).getDisplayName());
    }
  }
  return timezoneMap;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:11,代码来源:LocalDateUtil.java

示例13: testTimestampConversion

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * Tests that the escape tokenizer converts timestamp values
 * wrt. timezones when useTimezone=true.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testTimestampConversion() throws Exception {
    TimeZone currentTimezone = TimeZone.getDefault();
    String[] availableIds = TimeZone.getAvailableIDs(currentTimezone.getRawOffset() + (3600 * 1000 * 2));
    String newTimezone = null;

    if (availableIds.length > 0) {
        newTimezone = availableIds[0];
    } else {
        newTimezone = "UTC"; // punt
    }

    Properties props = new Properties();

    props.setProperty("useTimezone", "true");
    props.setProperty("serverTimezone", newTimezone);
    Connection tzConn = null;

    try {
        String escapeToken = "SELECT {ts '2002-11-12 10:00:00'} {t '05:11:02'}";
        tzConn = getConnectionWithProps(props);
        assertTrue(!tzConn.nativeSQL(escapeToken).equals(this.conn.nativeSQL(escapeToken)));
    } finally {
        if (tzConn != null) {
            tzConn.close();
        }
    }
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:35,代码来源:EscapeProcessingTest.java

示例14: Test4040996

import java.util.TimeZone; //导入方法依赖的package包/类
public void Test4040996() {
    String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
    SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
    pdt.setStartRule(APRIL, 1, SUNDAY, 2 * 60 * 60 * 1000);
    pdt.setEndRule(OCTOBER, -1, SUNDAY, 2 * 60 * 60 * 1000);
    Calendar calendar = new GregorianCalendar(pdt);

    calendar.set(MONTH, 3);
    calendar.set(DAY_OF_MONTH, 18);
    calendar.set(SECOND, 30);

    logln("MONTH: " + calendar.get(MONTH));
    logln("DAY_OF_MONTH: "
            + calendar.get(DAY_OF_MONTH));
    logln("MINUTE: " + calendar.get(MINUTE));
    logln("SECOND: " + calendar.get(SECOND));

    calendar.add(SECOND, 6);
    //This will print out todays date for MONTH and DAY_OF_MONTH
    //instead of the date it was set to.
    //This happens when adding MILLISECOND or MINUTE also
    logln("MONTH: " + calendar.get(MONTH));
    logln("DAY_OF_MONTH: "
            + calendar.get(DAY_OF_MONTH));
    logln("MINUTE: " + calendar.get(MINUTE));
    logln("SECOND: " + calendar.get(SECOND));
    if (calendar.get(MONTH) != 3
            || calendar.get(DAY_OF_MONTH) != 18
            || calendar.get(SECOND) != 36) {
        errln("Fail: Calendar.add misbehaves");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:CalendarRegression.java

示例15: timezonePopupClicked

import java.util.TimeZone; //导入方法依赖的package包/类
@Action
public void timezonePopupClicked(final NSPopUpButton sender) {
    String selected = sender.selectedItem().representedObject();
    String[] ids = TimeZone.getAvailableIDs();
    for(String id : ids) {
        TimeZone tz;
        if((tz = TimeZone.getTimeZone(id)).getID().equals(selected)) {
            bookmark.setTimezone(tz);
            break;
        }
    }
    this.update();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:DefaultBookmarkController.java


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