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


Java TimeZone.getID方法代码示例

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


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

示例1: main

import java.util.TimeZone; //导入方法依赖的package包/类
public static void main(String[] args) {

        TimeZone tz = TimeZone.getTimeZone("Asia/Taipei");
        Locale tzLocale = new Locale("ja");
        String jaStdName = "\u4e2d\u56fd\u6a19\u6e96\u6642";
        String jaDstName = "\u4e2d\u56fd\u590f\u6642\u9593";

        if (!tz.getDisplayName(false, TimeZone.LONG, tzLocale).equals
           (jaStdName))
             throw new RuntimeException("\n" + tzLocale + ": LONG, " +
                                        "non-daylight saving name for " +
                                        tz.getID() +
                                        " should be " +
                                        jaStdName);
        if (!tz.getDisplayName(true, TimeZone.LONG, tzLocale).equals
           (jaDstName))
             throw new RuntimeException("\n" + tzLocale + ": LONG, " +
                                        "daylight saving name for " +
                                        tz.getID() +
                                        " should be " +
                                        jaDstName);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Bug6442006.java

示例2: test

import java.util.TimeZone; //导入方法依赖的package包/类
private static void test(int offsetMinutes)
        throws DatatypeConfigurationException {
    XMLGregorianCalendar calendar = DatatypeFactory.newInstance().
            newXMLGregorianCalendar();
    calendar.setTimezone(60 + offsetMinutes);
    TimeZone timeZone = calendar.getTimeZone(DatatypeConstants.FIELD_UNDEFINED);
    String expected = (offsetMinutes < 10 ? "GMT+01:0" : "GMT+01:")
            + offsetMinutes;
    if (!timeZone.getID().equals(expected)) {
        throw new RuntimeException("Test failed: expected timezone: " +
                expected + " Actual: " + timeZone.getID());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:TestXMLGregorianCalendarTimeZone.java

示例3: main

import java.util.TimeZone; //导入方法依赖的package包/类
public static void main(String args[]) {
    ExecutorService executor = Executors.newFixedThreadPool(10);
    Callable<TimeZone> calTimeZone = () -> TimeZone.getDefault();
    List<Callable<TimeZone>> tasks = new ArrayList<>();
    for (int j = 1; j < 10; j++) {
        tasks.add(calTimeZone);
    }
    try {
        List<Future<TimeZone>> results = executor.invokeAll(tasks);
        for (Future<TimeZone> f : results) {
            TimeZone tz = f.get();
            if (! tz.getID().equals("GMT")) {
                throw new RuntimeException("wrong Time zone ID: " + tz.getID()
                        + ", It should be GMT");
            }
        }
    } catch (InterruptedException | ExecutionException e) {
        throw new RuntimeException("Execution interrupted or Execution Exception occurred", e);
    } finally {
        executor.shutdown();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Bug8066652.java

示例4: ProtocolOptions

import java.util.TimeZone; //导入方法依赖的package包/类
public ProtocolOptions ( final int timeout1, final int timeout2, final int timeout3, final ASDUAddressType adsuAddressType, final InformationObjectAddressType informationObjectAddressType, final CauseOfTransmissionType causeOfTransmissionType, final short maxUnacknowledged, final short acknowledgeWindow, final TimeZone timeZone, final boolean ignoreDaylightSavingTime )
{
    super ();
    this.timeout1 = timeout1;
    this.timeout2 = timeout2;
    this.timeout3 = timeout3;
    this.adsuAddressType = adsuAddressType;
    this.informationObjectAddressType = informationObjectAddressType;
    this.causeOfTransmissionType = causeOfTransmissionType;
    this.maxUnacknowledged = maxUnacknowledged;
    this.acknowledgeWindow = acknowledgeWindow;
    this.timeZone = timeZone;
    this.timeZoneId = timeZone != null ? timeZone.getID () : null;
    this.ignoreDaylightSavingTime = ignoreDaylightSavingTime;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:16,代码来源:ProtocolOptions.java

示例5: getTimeZone

import java.util.TimeZone; //导入方法依赖的package包/类
public static int getTimeZone() {

        TimeZone tz = TimeZone.getDefault();
        String displayName = tz.getDisplayName();
        int dstSavings = tz.getDSTSavings();
        String id = tz.getID();
        String displayName2 = tz.getDisplayName(false, TimeZone.SHORT);

        return 1;
    }
 
开发者ID:zeng3234,项目名称:GrowingProject,代码行数:11,代码来源:DateUtils.java

示例6: createTimezoneDTO

import java.util.TimeZone; //导入方法依赖的package包/类
/**
    * Returns new <code>Timezone</code> object with populated values.
    *
    * @param timeZone
    * @param selected
    * @return
    */
   public static TimezoneDTO createTimezoneDTO(TimeZone timeZone, boolean selected) {
TimezoneDTO timezoneDTO = new TimezoneDTO();
timezoneDTO.timeZoneId = timeZone.getID();
int timeZoneRawOffset = timeZone.getRawOffset();
timezoneDTO.rawOffset = new Date(Math.abs(timeZoneRawOffset));
timezoneDTO.isRawOffsetNegative = timeZoneRawOffset < 0;
timezoneDTO.dstOffset = timeZone.getDSTSavings() / 60000;
timezoneDTO.displayName = timeZone.getDisplayName();
timezoneDTO.selected = selected;
return timezoneDTO;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:TimezoneDTO.java

示例7: readObject

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * After reading an object from the input stream, the format
 * pattern in the object is verified.
 * <p>
 * @exception InvalidObjectException if the pattern is invalid
 */
private void readObject(ObjectInputStream stream)
                     throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    try {
        compiledPattern = compile(pattern);
    } catch (Exception e) {
        throw new InvalidObjectException("invalid pattern");
    }

    if (serialVersionOnStream < 1) {
        // didn't have defaultCenturyStart field
        initializeDefaultCentury();
    }
    else {
        // fill in dependent transient field
        parseAmbiguousDatesAsAfter(defaultCenturyStart);
    }
    serialVersionOnStream = currentSerialVersion;

    // If the deserialized object has a SimpleTimeZone, try
    // to replace it with a ZoneInfo equivalent in order to
    // be compatible with the SimpleTimeZone-based
    // implementation as much as possible.
    TimeZone tz = getTimeZone();
    if (tz instanceof SimpleTimeZone) {
        String id = tz.getID();
        TimeZone zi = TimeZone.getTimeZone(id);
        if (zi != null && zi.hasSameRules(tz) && zi.getID().equals(id)) {
            setTimeZone(zi);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:SimpleDateFormat.java

示例8: readObject

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * After reading an object from the input stream, the format
 * pattern in the object is verified.
 *
 * @exception InvalidObjectException if the pattern is invalid
 */
private void readObject(ObjectInputStream stream)
                     throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    try {
        compiledPattern = compile(pattern);
    } catch (Exception e) {
        throw new InvalidObjectException("invalid pattern");
    }

    if (serialVersionOnStream < 1) {
        // didn't have defaultCenturyStart field
        initializeDefaultCentury();
    }
    else {
        // fill in dependent transient field
        parseAmbiguousDatesAsAfter(defaultCenturyStart);
    }
    serialVersionOnStream = currentSerialVersion;

    // If the deserialized object has a SimpleTimeZone, try
    // to replace it with a ZoneInfo equivalent in order to
    // be compatible with the SimpleTimeZone-based
    // implementation as much as possible.
    TimeZone tz = getTimeZone();
    if (tz instanceof SimpleTimeZone) {
        String id = tz.getID();
        TimeZone zi = TimeZone.getTimeZone(id);
        if (zi != null && zi.hasSameRules(tz) && zi.getID().equals(id)) {
            setTimeZone(zi);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:SimpleDateFormat.java

示例9: getTimeZone

import java.util.TimeZone; //导入方法依赖的package包/类
public static String getTimeZone(Context context) {
    TimeZone tz = TimeZone.getDefault();
    String s = tz.getID();
    System.out.println(s);
    return s;
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:7,代码来源:PhoneMessage.java

示例10: timeZone

import java.util.TimeZone; //导入方法依赖的package包/类
private static String timeZone() {
    TimeZone tz = TimeZone.getDefault();
    return tz.getID();
}
 
开发者ID:MindorksOpenSource,项目名称:CrashReporter,代码行数:5,代码来源:AppUtils.java

示例11: timeZoneToString

import java.util.TimeZone; //导入方法依赖的package包/类
public static String timeZoneToString(TimeZone timeZone) {
	return timeZone == null ? null : timeZone.getID();
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:4,代码来源:CommonUtil.java

示例12: getAsText

import java.util.TimeZone; //导入方法依赖的package包/类
@Override
public String getAsText() {
	TimeZone value = (TimeZone) getValue();
	return (value != null ? value.getID() : "");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:TimeZoneEditor.java

示例13: toString

import java.util.TimeZone; //导入方法依赖的package包/类
public String toString(TimeZone value) {
	return value.getID();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:TimeZoneTypeDescriptor.java

示例14: timeZoneToDisplayString

import java.util.TimeZone; //导入方法依赖的package包/类
public static String timeZoneToDisplayString(TimeZone timeZone, Locale displayLocale) {
	return timeZone == null ? null : timeZone.getID();
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:4,代码来源:CommonUtil.java

示例15: getTimeZoneID

import java.util.TimeZone; //导入方法依赖的package包/类
public String getTimeZoneID() {
    TimeZone tz = TimeZone.getDefault();
    return (tz.getID());
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:5,代码来源:Device.java


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