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 {