當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。