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