Skip to content

Commit ce57100

Browse files
committed
backport 37b725d9c12834358a562e6c03fb7f566d639ca5
1 parent 0b3561a commit ce57100

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/java.base/share/classes/java/util/SimpleTimeZone.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -112,15 +112,15 @@
112112
* <pre><code>
113113
* // Base GMT offset: -8:00
114114
* // DST starts: at 2:00am in standard time
115-
* // on the first Sunday in April
115+
* // on the second Sunday in March
116116
* // DST ends: at 2:00am in daylight time
117-
* // on the last Sunday in October
117+
* // on the first Sunday in November
118118
* // Save: 1 hour
119119
* SimpleTimeZone(-28800000,
120120
* "America/Los_Angeles",
121-
* Calendar.APRIL, 1, -Calendar.SUNDAY,
121+
* Calendar.MARCH, 8, -Calendar.SUNDAY,
122122
* 7200000,
123-
* Calendar.OCTOBER, -1, Calendar.SUNDAY,
123+
* Calendar.NOVEMBER, 1, -Calendar.SUNDAY,
124124
* 7200000,
125125
* 3600000)
126126
*
@@ -857,13 +857,24 @@ public Object clone()
857857
}
858858

859859
/**
860-
* Generates the hash code for the SimpleDateFormat object.
860+
* Generates the hash code for the SimpleTimeZone object.
861861
* @return the hash code for this object
862862
*/
863863
public int hashCode()
864864
{
865-
return startMonth ^ startDay ^ startDayOfWeek ^ startTime ^
866-
endMonth ^ endDay ^ endDayOfWeek ^ endTime ^ rawOffset;
865+
int hash = 31 * getID().hashCode() + rawOffset;
866+
hash = 31 * hash + Boolean.hashCode(useDaylight);
867+
if (useDaylight) {
868+
hash = 31 * hash + startMonth;
869+
hash = 31 * hash + startDay;
870+
hash = 31 * hash + startDayOfWeek;
871+
hash = 31 * hash + startTime;
872+
hash = 31 * hash + endMonth;
873+
hash = 31 * hash + endDay;
874+
hash = 31 * hash + endDayOfWeek;
875+
hash = 31 * hash + endTime;
876+
}
877+
return hash;
867878
}
868879

869880
/**

0 commit comments

Comments
 (0)