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


Java TimeZone.hasSameRules方法代码示例

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


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

示例1: convert

import java.util.TimeZone; //导入方法依赖的package包/类
private static DateTimeValue convert(DateTimeValue time,
                                     TimeZone zone,
                                     int sense) {
    if (zone == null ||
            zone.hasSameRules(ZULU) ||
            time.year() == 0) {
        return time;
    }

    long timetMillis = 0;

    if (sense > 0) {
        // time is in UTC
        timetMillis = timetMillisFromEpochSecs(secsSinceEpoch(time), ZULU);
    } else {
        // time is in local time; since zone.getOffset() expects millis
        // in UTC, need to convert before we can get the offset (ironic)
        timetMillis = timetMillisFromEpochSecs(secsSinceEpoch(time), zone);
    }

    int millisecondOffset = zone.getOffset(timetMillis);
    int millisecondRound = millisecondOffset < 0 ? -500 : 500;
    int secondOffset = (millisecondOffset + millisecondRound) / 1000;
    return addSeconds(time, sense * secondOffset);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:26,代码来源:TimeUtils.java

示例2: timeZoneForName

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * returns the timezone with the given name or null if no such timezone.
 * calendar/common/ICalUtil uses this function
 */
public static TimeZone timeZoneForName(String tzString) {
    // This is a horrible hack since there is no easier way to get a timezone
    // only if the string is recognized as a timezone.
    // The TimeZone.getTimeZone javadoc says the following:
    //   Returns:
    //       the specified TimeZone, or the GMT zone if the given ID cannot be
    //       understood.
    TimeZone tz = TimeZone.getTimeZone(tzString);
    if (tz.hasSameRules(BOGUS_TIMEZONE)) {
        // see if the user really was asking for GMT because if
        // TimeZone.getTimeZone can't recognize tzString, then that is what it
        // will return.
        Matcher m = UTC_TZID.matcher(tzString);
        if (m.matches()) {
            return TimeUtils.utcTimezone();
        }
        // unrecognizable timezone
        return null;
    }
    return tz;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:26,代码来源:TimeUtils.java

示例3: 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:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:SimpleDateFormat.java

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


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