Package com.ibm.icu.util

Examples of com.ibm.icu.util.SimpleTimeZone


      return;
    }
    long current = System.currentTimeMillis();

    if (current < finalStartMillis) {
      SimpleTimeZone stz = new SimpleTimeZone(offsetMillis, getID());

      boolean bDst = useDaylightTime();
      if (bDst) {
        TimeZoneRule[] currentRules = getSimpleTimeZoneRulesNear(current);
        if (currentRules.length != 3) {
          // DST was observed at the beginning of this year, so useDaylightTime
          // returned true.  getSimpleTimeZoneRulesNear requires at least one
          // future transition for making a pair of rules.  This implementation
          // rolls back the time before the latest offset transition.
          TimeZoneTransition tzt = getPreviousTransition(current, false);
          if (tzt != null) {
            currentRules = getSimpleTimeZoneRulesNear(tzt.getTime() - 1);
          }
        }
        if (currentRules.length == 3 && (currentRules[1] instanceof AnnualTimeZoneRule)
            && (currentRules[2] instanceof AnnualTimeZoneRule)) {
          // A pair of AnnualTimeZoneRule
          AnnualTimeZoneRule r1 = (AnnualTimeZoneRule) currentRules[1];
          AnnualTimeZoneRule r2 = (AnnualTimeZoneRule) currentRules[2];
          DateTimeRule start, end;
          int offset1 = r1.getRawOffset() + r1.getDSTSavings();
          int offset2 = r2.getRawOffset() + r2.getDSTSavings();
          int sav;
          if (offset1 > offset2) {
            start = r1.getRule();
            end = r2.getRule();
            sav = offset1 - offset2;
          } else {
            start = r2.getRule();
            end = r1.getRule();
            sav = offset2 - offset1;
          }
          // getSimpleTimeZoneRulesNear always return rules using DOW / WALL_TIME
          stz.setStartRule(start.getRuleMonth(), start.getRuleWeekInMonth(), start.getRuleDayOfWeek(), start.getRuleMillisInDay());
          stz.setEndRule(end.getRuleMonth(), end.getRuleWeekInMonth(), end.getRuleDayOfWeek(), end.getRuleMillisInDay());
          // set DST saving amount and start year
          stz.setDSTSavings(sav);
        } else {
          // This could only happen if last rule is DST
          // and the rule used forever.  For example, Asia/Dhaka
          // in tzdata2009i stays in DST forever.

          // Hack - set DST starting at midnight on Jan 1st,
          // ending 23:59:59.999 on Dec 31st
          stz.setStartRule(0, 1, 0);
          stz.setEndRule(11, 31, Grego.MILLIS_PER_DAY - 1);
        }
      }

      int[] fields = Grego.timeToFields(current, null);

      finalStartYear = fields[0];
      finalStartMillis = Grego.fieldsToDay(fields[0], 0, 1);

      if (bDst) {
        // we probably do not need to set start year of final rule
        // to finalzone itself, but we always do this for now.
        stz.setStartYear(finalStartYear);
      }

      finalZone = stz;

    } else {
View Full Code Here


      int[] ruleData = r.getIntVector();

      if (ruleData == null || ruleData.length != 11) {
        throw new IllegalArgumentException("Invalid Format");
      }
      finalZone = new SimpleTimeZone(ruleRaw, "", ruleData[0], ruleData[1], ruleData[2], ruleData[3] * Grego.MILLIS_PER_SECOND,
          ruleData[4], ruleData[5], ruleData[6], ruleData[7], ruleData[8] * Grego.MILLIS_PER_SECOND, ruleData[9], ruleData[10]
              * Grego.MILLIS_PER_SECOND);

      r = res.get("finalYear");
      finalStartYear = r.getInt();
View Full Code Here

            return;
        }
        long current = System.currentTimeMillis();

        if (current < finalStartMillis) {
            SimpleTimeZone stz = new SimpleTimeZone(offsetMillis, getID());

            boolean bDst = useDaylightTime();
            if (bDst) {
                TimeZoneRule[] currentRules = getSimpleTimeZoneRulesNear(current);
                if (currentRules.length != 3) {
                    // DST was observed at the beginning of this year, so useDaylightTime
                    // returned true.  getSimpleTimeZoneRulesNear requires at least one
                    // future transition for making a pair of rules.  This implementation
                    // rolls back the time before the latest offset transition.
                    TimeZoneTransition tzt = getPreviousTransition(current, false);
                    if (tzt != null) {
                        currentRules = getSimpleTimeZoneRulesNear(tzt.getTime() - 1);
                    }
                }
                if (currentRules.length == 3
                        && (currentRules[1] instanceof AnnualTimeZoneRule)
                        && (currentRules[2] instanceof AnnualTimeZoneRule)) {
                    // A pair of AnnualTimeZoneRule
                    AnnualTimeZoneRule r1 = (AnnualTimeZoneRule)currentRules[1];
                    AnnualTimeZoneRule r2 = (AnnualTimeZoneRule)currentRules[2];
                    DateTimeRule start, end;
                    int offset1 = r1.getRawOffset() + r1.getDSTSavings();
                    int offset2 = r2.getRawOffset() + r2.getDSTSavings();
                    int sav;
                    if (offset1 > offset2) {
                        start = r1.getRule();
                        end = r2.getRule();
                        sav = offset1 - offset2;
                    } else {
                        start = r2.getRule();
                        end = r1.getRule();
                        sav = offset2 - offset1;
                    }
                    // getSimpleTimeZoneRulesNear always return rules using DOW / WALL_TIME
                    stz.setStartRule(start.getRuleMonth(), start.getRuleWeekInMonth(), start.getRuleDayOfWeek(),
                                            start.getRuleMillisInDay());
                    stz.setEndRule(end.getRuleMonth(), end.getRuleWeekInMonth(), end.getRuleDayOfWeek(),
                                            end.getRuleMillisInDay());
                    // set DST saving amount and start year
                    stz.setDSTSavings(sav);
                } else {
                    // This could only happen if last rule is DST
                    // and the rule used forever.  For example, Asia/Dhaka
                    // in tzdata2009i stays in DST forever.

                    // Hack - set DST starting at midnight on Jan 1st,
                    // ending 23:59:59.999 on Dec 31st
                    stz.setStartRule(0, 1, 0);
                    stz.setEndRule(11, 31, Grego.MILLIS_PER_DAY - 1);
                }
            }

            int[] fields = Grego.timeToFields(current, null);

            finalStartYear = fields[0];
            finalStartMillis = Grego.fieldsToDay(fields[0], 0, 1);

            if (bDst) {
                // we probably do not need to set start year of final rule
                // to finalzone itself, but we always do this for now.
                stz.setStartYear(finalStartYear);
            }

            finalZone = stz;

        } else {
View Full Code Here

            int[] ruleData = r.getIntVector();

            if (ruleData == null || ruleData.length != 11) {
                throw new IllegalArgumentException("Invalid Format");
            }
            finalZone = new SimpleTimeZone(ruleRaw, "",
                    ruleData[0], ruleData[1], ruleData[2],
                    ruleData[3] * Grego.MILLIS_PER_SECOND,
                    ruleData[4],
                    ruleData[5], ruleData[6], ruleData[7],
                    ruleData[8] * Grego.MILLIS_PER_SECOND,
 
View Full Code Here

        }
        return (TimeZone)z.clone();
    }

    public static TimeZone getGMT(){
        TimeZone z = new SimpleTimeZone(0, kGMT_ID);
        z.setID(kGMT_ID);
        return z;
    }
View Full Code Here

    public static TimeZone getCustomTimeZone(String id){
        int[] fields = new int[4];
        if (parseCustomID(id, fields)) {
            String zid = formatCustomID(fields[1], fields[2], fields[3], fields[0] < 0);
            int offset = fields[0] * ((fields[1] * 60 + fields[2]) * 60 + fields[3]) * 1000;
            return new SimpleTimeZone(offset, zid);
        }
        return null;
    }
View Full Code Here

        hour = tmp / 60;

        // Note: No millisecond part included in TZID for now
        String zid = formatCustomID(hour, min, sec, negative);

        return new SimpleTimeZone(offset, zid);
    }
View Full Code Here

            finalYear = tmpFinalYear;
            finalMillis = Grego.fieldsToDay(tmpFinalYear, 0, 1) * Grego.MILLIS_PER_DAY;
        }
        if (finalZone == null) {
            // Create SimpleTimeZone instance to store the offset
            finalZone = new SimpleTimeZone(offsetMillis, getID());
        } else {
            finalZone.setRawOffset(offsetMillis);
            finalZone.setStartYear(finalYear);
        }

View Full Code Here

                // 3, 1, -1, 7200, 0, 9, -31, -1, 7200, 0, 3600
                data = r.getIntVector();
                if ( data.length == 11) {
                    //U_DEBUG_TZ_MSG(("zone%s, rule%s: {%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d}", zKey, ures_getKey(r),
                      //            data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10]));
                    finalZone = new SimpleTimeZone(rawOffset, "",
                        data[0], data[1], data[2],
                        data[3] * Grego.MILLIS_PER_SECOND,
                        data[4],
                        data[5], data[6], data[7],
                        data[8] * Grego.MILLIS_PER_SECOND,
 
View Full Code Here

        }
        return (TimeZone)z.clone();
    }
   
    public static TimeZone getGMT(){
        TimeZone z = new SimpleTimeZone(0, kGMT_ID);
        z.setID(kGMT_ID);
        return z;
    }
View Full Code Here

TOP

Related Classes of com.ibm.icu.util.SimpleTimeZone

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.