本文整理汇总了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);
}
示例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());
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例10: timeZone
import java.util.TimeZone; //导入方法依赖的package包/类
private static String timeZone() {
TimeZone tz = TimeZone.getDefault();
return tz.getID();
}
示例11: timeZoneToString
import java.util.TimeZone; //导入方法依赖的package包/类
public static String timeZoneToString(TimeZone timeZone) {
return timeZone == null ? null : timeZone.getID();
}
示例12: getAsText
import java.util.TimeZone; //导入方法依赖的package包/类
@Override
public String getAsText() {
TimeZone value = (TimeZone) getValue();
return (value != null ? value.getID() : "");
}
示例13: toString
import java.util.TimeZone; //导入方法依赖的package包/类
public String toString(TimeZone value) {
return value.getID();
}
示例14: timeZoneToDisplayString
import java.util.TimeZone; //导入方法依赖的package包/类
public static String timeZoneToDisplayString(TimeZone timeZone, Locale displayLocale) {
return timeZone == null ? null : timeZone.getID();
}
示例15: getTimeZoneID
import java.util.TimeZone; //导入方法依赖的package包/类
public String getTimeZoneID() {
TimeZone tz = TimeZone.getDefault();
return (tz.getID());
}