mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-26 07:40:09 +00:00
8066571: UnsupportedTemporalTypeException is thrown not only in the case of unsupported temporal - Java Bug System
Reviewed-by: rriggs, scolebourne
This commit is contained in:
parent
cda93faedc
commit
dd0226189c
@ -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:
|
||||
* <ul>
|
||||
* <li>{@link #DAY_OF_QUARTER DAY_OF_QUARTER} - the day within the quarter, from 1 to 90, 91 or 92
|
||||
* <li>{@link #QUARTER_OF_YEAR QUARTER_OF_YEAR} - the week within the week-based-year
|
||||
* <li>{@link #QUARTER_OF_YEAR QUARTER_OF_YEAR} - the quarter within the year, from 1 to 4
|
||||
* <li>{@link ChronoField#YEAR YEAR} - the standard ISO year
|
||||
* </ul>
|
||||
*
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user