diff --git a/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java b/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java index 76528c4e7dd..73ebdf40abf 100644 --- a/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java +++ b/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ import sun.util.locale.provider.LocaleResources; * The complete date is expressed using three fields: * * @@ -571,9 +571,6 @@ public final class IsoFields { //------------------------------------------------------------------------- private static final int[] QUARTER_DAYS = {0, 90, 181, 273, 0, 91, 182, 274}; - private static boolean isIso(TemporalAccessor temporal) { - return Chronology.from(temporal).equals(IsoChronology.INSTANCE); - } private static void ensureIso(TemporalAccessor temporal) { if (isIso(temporal) == false) { @@ -681,7 +678,7 @@ public final class IsoFields { @Override public boolean isSupportedBy(Temporal temporal) { - return temporal.isSupported(EPOCH_DAY); + return temporal.isSupported(EPOCH_DAY) && isIso(temporal); } @SuppressWarnings("unchecked") @@ -721,4 +718,8 @@ public final class IsoFields { return name; } } + + static boolean isIso(TemporalAccessor temporal) { + return Chronology.from(temporal).equals(IsoChronology.INSTANCE); + } } diff --git a/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java b/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java index d79d13f89a3..672295e4def 100644 --- a/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java +++ b/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014,2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -121,6 +121,14 @@ public class TestIsoWeekFields { assertEquals(IsoFields.WEEK_BASED_YEAR.isSupportedBy(ThaiBuddhistDate.now()), false); } + @Test + public void test_Unit_isSupportedBy_ISO() { + assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(LocalDate.now()),true); + assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(ThaiBuddhistDate.now()),false); + assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(LocalDate.now()),true); + assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(ThaiBuddhistDate.now()),false); + } + @Test(dataProvider = "fields") public void test_WBY_range(TemporalField weekField, TemporalField yearField) { assertEquals(yearField.range(), ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE));