Skip to content

Commit 58107e5

Browse files
committedJul 31, 2020
8233048: WeekFields.ISO is not a singleton
Reviewed-by: joehw, rriggs, scolebourne
1 parent 0f5e57a commit 58107e5

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
 

‎src/java.base/share/classes/java/time/temporal/WeekFields.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, 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
@@ -210,7 +210,7 @@ public final class WeekFields implements Serializable {
210210
* Note also that the first few days of a calendar year may be in the
211211
* week-based-year corresponding to the previous calendar year.
212212
*/
213-
public static final WeekFields ISO = new WeekFields(DayOfWeek.MONDAY, 4);
213+
public static final WeekFields ISO = WeekFields.of(DayOfWeek.MONDAY, 4);
214214

215215
/**
216216
* The common definition of a week that starts on Sunday and the first week

‎test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, 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
@@ -26,7 +26,9 @@
2626

2727
import static java.time.temporal.ChronoField.DAY_OF_WEEK;
2828
import static org.testng.Assert.assertEquals;
29+
import static org.testng.Assert.assertTrue;
2930

31+
import java.time.DayOfWeek;
3032
import java.time.LocalDate;
3133
import java.time.LocalTime;
3234
import java.time.MonthDay;
@@ -281,6 +283,11 @@ public void test_addTo_weekBasedYears(TemporalField weekField, TemporalField yea
281283
}
282284
}
283285

286+
@Test
287+
public void test_ISOSingleton() {
288+
assertTrue(WeekFields.ISO == WeekFields.of(DayOfWeek.MONDAY, 4));
289+
}
290+
284291
private int wbyLen(int wby) {
285292
return (wby == 2004 || wby == 2009 || wby == 2015 || wby == 2020 ? 53 : 52);
286293
}

0 commit comments

Comments
 (0)
Please sign in to comment.