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


Java TimeZone.useDaylightTime方法代码示例

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


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

示例1: appendTo

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void appendTo(StringBuffer buffer, Calendar calendar) {
    if (mTimeZoneForced) {
        if (mTimeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(mDaylight);
        } else {
            buffer.append(mStandard);
        }
    } else {
        TimeZone timeZone = calendar.getTimeZone();
        if (timeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(getTimeZoneDisplay(timeZone, true, mStyle, mLocale));
        } else {
            buffer.append(getTimeZoneDisplay(timeZone, false, mStyle, mLocale));
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:FastDateFormat.java

示例2: appendTo

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void appendTo(final StringBuffer buffer, final Calendar calendar) {
    final TimeZone zone = calendar.getTimeZone();
    if (zone.useDaylightTime()
            && calendar.get(Calendar.DST_OFFSET) != 0) {
        buffer.append(getTimeZoneDisplay(zone, true, mStyle, mLocale));
    } else {
        buffer.append(getTimeZoneDisplay(zone, false, mStyle, mLocale));
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:14,代码来源:FastDatePrinter.java

示例3: hasSameRules

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * Returns true if this zone has the same raw GMT offset value and
 * transition table as another zone info. If the specified
 * TimeZone object is not a ZoneInfo instance, this method returns
 * true if the specified TimeZone object has the same raw GMT
 * offset value with no daylight saving time.
 *
 * @param other the ZoneInfo object to be compared with
 * @return true if the given <code>TimeZone</code> has the same
 * GMT offset and transition information; false, otherwise.
 */
public boolean hasSameRules(TimeZone other) {
    if (this == other) {
        return true;
    }
    if (other == null) {
        return false;
    }
    if (!(other instanceof ZoneInfo)) {
        if (getRawOffset() != other.getRawOffset()) {
            return false;
        }
        // if both have the same raw offset and neither observes
        // DST, they have the same rule.
        if ((transitions == null)
            && (useDaylightTime() == false)
            && (other.useDaylightTime() == false)) {
            return true;
        }
        return false;
    }
    if (getLastRawOffset() != ((ZoneInfo)other).getLastRawOffset()) {
        return false;
    }
    return (checksum == ((ZoneInfo)other).checksum);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:ZoneInfo.java

示例4: hasSameRules

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * Returns true if this zone has the same raw GMT offset value and
 * transition table as another zone info. If the specified
 * TimeZone object is not a ZoneInfoOld instance, this method returns
 * true if the specified TimeZone object has the same raw GMT
 * offset value with no daylight saving time.
 *
 * @param other the ZoneInfoOld object to be compared with
 * @return true if the given <code>TimeZone</code> has the same
 * GMT offset and transition information; false, otherwise.
 */
public boolean hasSameRules(TimeZone other) {
    if (this == other) {
        return true;
    }
    if (other == null) {
        return false;
    }
    if (!(other instanceof ZoneInfoOld)) {
        if (getRawOffset() != other.getRawOffset()) {
            return false;
        }
        // if both have the same raw offset and neither observes
        // DST, they have the same rule.
        if ((transitions == null)
            && (useDaylightTime() == false)
            && (other.useDaylightTime() == false)) {
            return true;
        }
        return false;
    }
    if (getLastRawOffset() != ((ZoneInfoOld)other).getLastRawOffset()) {
        return false;
    }
    return (checksum == ((ZoneInfoOld)other).checksum);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:ZoneInfoOld.java

示例5: calculateGMTOffset

import java.util.TimeZone; //导入方法依赖的package包/类
private String calculateGMTOffset()
{
    String sign = "+";
    TimeZone timeZone = TimeZone.getDefault();
    int offset = timeZone.getRawOffset();
    if (offset < 0)
    {
        sign = "-";
        offset = -offset;
    }
    int hours = offset / (60 * 60 * 1000);
    int minutes = (offset - (hours * 60 * 60 * 1000)) / (60 * 1000);

    try
    {
        if (timeZone.useDaylightTime() && timeZone.inDaylightTime(this.getDate()))
        {
            hours += sign.equals("+") ? 1 : -1;
        }
    }
    catch (ParseException e)
    {
        // we'll do our best and ignore daylight savings
    }

    return "GMT" + sign + convert(hours) + ":" + convert(minutes);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:28,代码来源:DERGeneralizedTime.java

示例6: TimeZoneStrategy

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * Construct a Strategy that parses a TimeZone
 *
 * @param locale The Locale
 */
TimeZoneStrategy(final Locale locale) {
    final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings();
    for (String[] zone : zones) {
        if (zone[ID].startsWith("GMT")) {
            continue;
        }
        final TimeZone tz = TimeZone.getTimeZone(zone[ID]);
        if (!tzNames.containsKey(zone[LONG_STD])) {
            tzNames.put(zone[LONG_STD], tz);
        }
        if (!tzNames.containsKey(zone[SHORT_STD])) {
            tzNames.put(zone[SHORT_STD], tz);
        }
        if (tz.useDaylightTime()) {
            if (!tzNames.containsKey(zone[LONG_DST])) {
                tzNames.put(zone[LONG_DST], tz);
            }
            if (!tzNames.containsKey(zone[SHORT_DST])) {
                tzNames.put(zone[SHORT_DST], tz);
            }
        }
    }

    final StringBuilder sb = new StringBuilder();
    sb.append("(GMT[+\\-]\\d{0,1}\\d{2}|[+\\-]\\d{2}:?\\d{2}|");
    for (final String id : tzNames.keySet()) {
        escapeRegex(sb, id, false).append('|');
    }
    sb.setCharAt(sb.length() - 1, ')');
    validTimeZoneChars = sb.toString();
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:37,代码来源:FastDateParser.java

示例7: main

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

    Calendar cal = new GregorianCalendar(BEGIN_YEAR, MARCH, 1);
    String[] tzids = TimeZone.getAvailableIDs();
    try {
        for (String id : tzids) {
            TimeZone tz = TimeZone.getTimeZone(id);
            if (!tz.useDaylightTime()) {
                continue;
            }
            TimeZone.setDefault(tz);

          dateloop:
            // Use future dates because sun.util.calendar.ZoneInfo
            // delegates offset transition calculations to a SimpleTimeZone
            // (after 2038 as of JDK7).
            for (int year = BEGIN_YEAR; year < END_YEAR; year++) {
                for (int month = MARCH; month <= NOVEMBER; month++) {
                    cal.set(year, month, 1, 15, 0, 0);
                    int maxDom = cal.getActualMaximum(DAY_OF_MONTH);
                    for (int dom = 1; dom <= maxDom; dom++) {
                        Date date = new Date(year - 1900, month, dom);
                        if (date.getYear()+1900 != year
                            || date.getMonth() != month
                            || date.getDate() != dom) {
                            System.err.printf("%s: got %04d-%02d-%02d, expected %04d-%02d-%02d%n",
                                              id,
                                              date.getYear() + 1900,
                                              date.getMonth() + 1,
                                              date.getDate(),
                                              year,
                                              month + 1,
                                              dom);
                            errors++;
                            break dateloop;
                        }
                    }
                }
            }
        }
    } finally {
        // Restore the default TimeZone.
        TimeZone.setDefault(defaultTimeZone);
    }
    if (errors > 0) {
        throw new RuntimeException("Transition test failed");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:51,代码来源:Bug6772689.java

示例8: getDSTSavings

import java.util.TimeZone; //导入方法依赖的package包/类
/**
 * <p>
 * Equivalent of TimeZone.getDSTSavings() in JDK 1.4, but Quartz is trying
 * to support JDK 1.3.
 * </p>
 * 
 * @param tz the target time-zone
 * @return the amount of saving time in milliseconds
 * @deprecated use TimeZone.getDSTSavings()
 */
public static int getDSTSavings(TimeZone tz) {
    
    if (tz.useDaylightTime()) {
        return 3600000;
    }
    return 0;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:18,代码来源:TriggerUtils.java


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