Skip to content

Commit 373e37b

Browse files
author
Justin Lu
committed
8313813: Field sun.util.calendar.CalendarDate#forceStandardTime is never set
Reviewed-by: aturbanov, naoto
1 parent 5308bbb commit 373e37b

File tree

3 files changed

+10
-48
lines changed

3 files changed

+10
-48
lines changed

src/java.base/share/classes/sun/util/calendar/AbstractCalendar.java

+10-23
Original file line numberDiff line numberDiff line change
@@ -165,31 +165,18 @@ public long getTime(CalendarDate date) {
165165
if (date.isNormalized()) {
166166
return ms - date.getZoneOffset();
167167
}
168+
168169
// adjust time zone and daylight saving
169-
int[] offsets = new int[2];
170-
if (date.isStandardTime()) {
171-
// 1) 2:30am during starting-DST transition is
172-
// intrepreted as 2:30am ST
173-
// 2) 5:00pm during DST is still interpreted as 5:00pm ST
174-
// 3) 1:30am during ending-DST transition is interpreted
175-
// as 1:30am ST (after transition)
176-
if (zi instanceof ZoneInfo) {
177-
((ZoneInfo)zi).getOffsetsByStandard(ms, offsets);
178-
zoneOffset = offsets[0];
179-
} else {
180-
zoneOffset = zi.getOffset(ms - zi.getRawOffset());
181-
}
170+
// 1) 2:30am during starting-DST transition is
171+
// interpreted as 3:30am DT
172+
// 2) 5:00pm during DST is interpreted as 5:00pm DT
173+
// 3) 1:30am during ending-DST transition is interpreted
174+
// as 1:30am DT/0:30am ST (before transition)
175+
if (zi instanceof ZoneInfo zInfo) {
176+
// Offset value adjusts accordingly depending on DST status of date
177+
zoneOffset = zInfo.getOffsetsByWall(ms, new int[2]);
182178
} else {
183-
// 1) 2:30am during starting-DST transition is
184-
// intrepreted as 3:30am DT
185-
// 2) 5:00pm during DST is intrepreted as 5:00pm DT
186-
// 3) 1:30am during ending-DST transition is interpreted
187-
// as 1:30am DT/0:30am ST (before transition)
188-
if (zi instanceof ZoneInfo) {
189-
zoneOffset = ((ZoneInfo)zi).getOffsetsByWall(ms, offsets);
190-
} else {
191-
zoneOffset = zi.getOffset(ms - zi.getRawOffset());
192-
}
179+
zoneOffset = zi.getOffset(ms - zi.getRawOffset());
193180
}
194181
}
195182
ms -= zoneOffset;

src/java.base/share/classes/sun/util/calendar/CalendarDate.java

-16
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
package sun.util.calendar;
2727

2828
import java.lang.Cloneable;
29-
import java.util.Locale;
3029
import java.util.TimeZone;
3130

3231
/**
@@ -82,9 +81,6 @@ public abstract class CalendarDate implements Cloneable {
8281
private TimeZone zoneinfo;
8382
private int zoneOffset;
8483
private int daylightSaving;
85-
private boolean forceStandardTime;
86-
87-
private Locale locale;
8884

8985
protected CalendarDate() {
9086
this(TimeZone.getDefault());
@@ -293,22 +289,10 @@ public boolean isNormalized() {
293289
return normalized;
294290
}
295291

296-
297-
public boolean isStandardTime() {
298-
return forceStandardTime;
299-
}
300-
301292
public boolean isDaylightTime() {
302-
if (isStandardTime()) {
303-
return false;
304-
}
305293
return daylightSaving != 0;
306294
}
307295

308-
protected void setLocale(Locale loc) {
309-
locale = loc;
310-
}
311-
312296
public TimeZone getZone() {
313297
return zoneinfo;
314298
}

src/java.base/share/classes/sun/util/calendar/ImmutableGregorianDate.java

-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
package sun.util.calendar;
2727

28-
import java.util.Locale;
2928
import java.util.TimeZone;
3029

3130
class ImmutableGregorianDate extends BaseCalendar.Date {
@@ -146,18 +145,10 @@ public boolean isNormalized() {
146145
return date.isNormalized();
147146
}
148147

149-
public boolean isStandardTime() {
150-
return date.isStandardTime();
151-
}
152-
153148
public boolean isDaylightTime() {
154149
return date.isDaylightTime();
155150
}
156151

157-
protected void setLocale(Locale loc) {
158-
unsupported();
159-
}
160-
161152
public TimeZone getZone() {
162153
return date.getZone();
163154
}

0 commit comments

Comments
 (0)