Java Code Examples for java.time.format.ResolverStyle#STRICT

The following examples show how to use java.time.format.ResolverStyle#STRICT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JapaneseChronology.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override  // override for special Japanese behavior
ChronoLocalDate resolveYearOfEra(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    // validate era and year-of-era
    Long eraLong = fieldValues.get(ERA);
    JapaneseEra era = null;
    if (eraLong != null) {
        era = eraOf(range(ERA).checkValidIntValue(eraLong, ERA));  // always validated
    }
    Long yoeLong = fieldValues.get(YEAR_OF_ERA);
    int yoe = 0;
    if (yoeLong != null) {
        yoe = range(YEAR_OF_ERA).checkValidIntValue(yoeLong, YEAR_OF_ERA);  // always validated
    }
    // if only year-of-era and no year then invent era unless strict
    if (era == null && yoeLong != null && fieldValues.containsKey(YEAR) == false && resolverStyle != ResolverStyle.STRICT) {
        era = JapaneseEra.values()[JapaneseEra.values().length - 1];
    }
    // if both present, then try to create date
    if (yoeLong != null && era != null) {
        if (fieldValues.containsKey(MONTH_OF_YEAR)) {
            if (fieldValues.containsKey(DAY_OF_MONTH)) {
                return resolveYMD(era, yoe, fieldValues, resolverStyle);
            }
        }
        if (fieldValues.containsKey(DAY_OF_YEAR)) {
            return resolveYD(era, yoe, fieldValues, resolverStyle);
        }
    }
    return null;
}
 
Example 2
Source File: IsoChronology.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
@Override  // override for enhanced behaviour
LocalDate resolveYearOfEra(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    Long yoeLong = fieldValues.remove(YEAR_OF_ERA);
    if (yoeLong != null) {
        if (resolverStyle != ResolverStyle.LENIENT) {
            YEAR_OF_ERA.checkValidValue(yoeLong);
        }
        Long era = fieldValues.remove(ERA);
        if (era == null) {
            Long year = fieldValues.get(YEAR);
            if (resolverStyle == ResolverStyle.STRICT) {
                // do not invent era if strict, but do cross-check with year
                if (year != null) {
                    addFieldValue(fieldValues, YEAR, (year > 0 ? yoeLong: Math.subtractExact(1, yoeLong)));
                } else {
                    // reinstate the field removed earlier, no cross-check issues
                    fieldValues.put(YEAR_OF_ERA, yoeLong);
                }
            } else {
                // invent era
                addFieldValue(fieldValues, YEAR, (year == null || year > 0 ? yoeLong: Math.subtractExact(1, yoeLong)));
            }
        } else if (era.longValue() == 1L) {
            addFieldValue(fieldValues, YEAR, yoeLong);
        } else if (era.longValue() == 0L) {
            addFieldValue(fieldValues, YEAR, Math.subtractExact(1, yoeLong));
        } else {
            throw new DateTimeException("Invalid value for era: " + era);
        }
    } else if (fieldValues.containsKey(ERA)) {
        ERA.checkValidValue(fieldValues.get(ERA));  // always validated
    }
    return null;
}
 
Example 3
Source File: AbstractChronology.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
ChronoLocalDate resolveYAA(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR);
    if (resolverStyle == ResolverStyle.LENIENT) {
        long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1);
        long days = Math.subtractExact(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), 1);
        return dateYearDay(y, 1).plus(weeks, WEEKS).plus(days, DAYS);
    }
    int aw = range(ALIGNED_WEEK_OF_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), ALIGNED_WEEK_OF_YEAR);
    int ad = range(ALIGNED_DAY_OF_WEEK_IN_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), ALIGNED_DAY_OF_WEEK_IN_YEAR);
    ChronoLocalDate date = dateYearDay(y, 1).plus((aw - 1) * 7 + (ad - 1), DAYS);
    if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) {
        throw new DateTimeException("Strict mode rejected resolved date as it is in a different year");
    }
    return date;
}
 
Example 4
Source File: IsoFields.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    Long yearLong = fieldValues.get(YEAR);
    Long qoyLong = fieldValues.get(QUARTER_OF_YEAR);
    if (yearLong == null || qoyLong == null) {
        return null;
    }
    int y = YEAR.checkValidIntValue(yearLong);  // always validate
    long doq = fieldValues.get(DAY_OF_QUARTER);
    ensureIso(partialTemporal);
    LocalDate date;
    if (resolverStyle == ResolverStyle.LENIENT) {
        date = LocalDate.of(y, 1, 1).plusMonths(Math.multiplyExact(Math.subtractExact(qoyLong, 1), 3));
        doq = Math.subtractExact(doq, 1);
    } else {
        int qoy = QUARTER_OF_YEAR.range().checkValidIntValue(qoyLong, QUARTER_OF_YEAR);  // validated
        date = LocalDate.of(y, ((qoy - 1) * 3) + 1, 1);
        if (doq < 1 || doq > 90) {
            if (resolverStyle == ResolverStyle.STRICT) {
                rangeRefinedBy(date).checkValidValue(doq, this);  // only allow exact range
            } else {  // SMART
                range().checkValidValue(doq, this);  // allow 1-92 rolling into next quarter
            }
        }
        doq--;
    }
    fieldValues.remove(this);
    fieldValues.remove(YEAR);
    fieldValues.remove(QUARTER_OF_YEAR);
    return date.plusDays(doq);
}
 
Example 5
Source File: IsoChronology.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override  // override for enhanced behaviour
LocalDate resolveYearOfEra(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    Long yoeLong = fieldValues.remove(YEAR_OF_ERA);
    if (yoeLong != null) {
        if (resolverStyle != ResolverStyle.LENIENT) {
            YEAR_OF_ERA.checkValidValue(yoeLong);
        }
        Long era = fieldValues.remove(ERA);
        if (era == null) {
            Long year = fieldValues.get(YEAR);
            if (resolverStyle == ResolverStyle.STRICT) {
                // do not invent era if strict, but do cross-check with year
                if (year != null) {
                    addFieldValue(fieldValues, YEAR, (year > 0 ? yoeLong: Math.subtractExact(1, yoeLong)));
                } else {
                    // reinstate the field removed earlier, no cross-check issues
                    fieldValues.put(YEAR_OF_ERA, yoeLong);
                }
            } else {
                // invent era
                addFieldValue(fieldValues, YEAR, (year == null || year > 0 ? yoeLong: Math.subtractExact(1, yoeLong)));
            }
        } else if (era.longValue() == 1L) {
            addFieldValue(fieldValues, YEAR, yoeLong);
        } else if (era.longValue() == 0L) {
            addFieldValue(fieldValues, YEAR, Math.subtractExact(1, yoeLong));
        } else {
            throw new DateTimeException("Invalid value for era: " + era);
        }
    } else if (fieldValues.containsKey(ERA)) {
        ERA.checkValidValue(fieldValues.get(ERA));  // always validated
    }
    return null;
}
 
Example 6
Source File: IsoFields.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    Long yearLong = fieldValues.get(YEAR);
    Long qoyLong = fieldValues.get(QUARTER_OF_YEAR);
    if (yearLong == null || qoyLong == null) {
        return null;
    }
    int y = YEAR.checkValidIntValue(yearLong);  // always validate
    long doq = fieldValues.get(DAY_OF_QUARTER);
    ensureIso(partialTemporal);
    LocalDate date;
    if (resolverStyle == ResolverStyle.LENIENT) {
        date = LocalDate.of(y, 1, 1).plusMonths(Math.multiplyExact(Math.subtractExact(qoyLong, 1), 3));
        doq = Math.subtractExact(doq, 1);
    } else {
        int qoy = QUARTER_OF_YEAR.range().checkValidIntValue(qoyLong, QUARTER_OF_YEAR);  // validated
        date = LocalDate.of(y, ((qoy - 1) * 3) + 1, 1);
        if (doq < 1 || doq > 90) {
            if (resolverStyle == ResolverStyle.STRICT) {
                rangeRefinedBy(date).checkValidValue(doq, this);  // only allow exact range
            } else {  // SMART
                range().checkValidValue(doq, this);  // allow 1-92 rolling into next quarter
            }
        }
        doq--;
    }
    fieldValues.remove(this);
    fieldValues.remove(YEAR);
    fieldValues.remove(QUARTER_OF_YEAR);
    return date.plusDays(doq);
}
 
Example 7
Source File: IsoFields.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    Long yearLong = fieldValues.get(YEAR);
    Long qoyLong = fieldValues.get(QUARTER_OF_YEAR);
    if (yearLong == null || qoyLong == null) {
        return null;
    }
    int y = YEAR.checkValidIntValue(yearLong);  // always validate
    long doq = fieldValues.get(DAY_OF_QUARTER);
    ensureIso(partialTemporal);
    LocalDate date;
    if (resolverStyle == ResolverStyle.LENIENT) {
        date = LocalDate.of(y, 1, 1).plusMonths(Math.multiplyExact(Math.subtractExact(qoyLong, 1), 3));
        doq = Math.subtractExact(doq, 1);
    } else {
        int qoy = QUARTER_OF_YEAR.range().checkValidIntValue(qoyLong, QUARTER_OF_YEAR);  // validated
        date = LocalDate.of(y, ((qoy - 1) * 3) + 1, 1);
        if (doq < 1 || doq > 90) {
            if (resolverStyle == ResolverStyle.STRICT) {
                rangeRefinedBy(date).checkValidValue(doq, this);  // only allow exact range
            } else {  // SMART
                range().checkValidValue(doq, this);  // allow 1-92 rolling into next quarter
            }
        }
        doq--;
    }
    fieldValues.remove(this);
    fieldValues.remove(YEAR);
    fieldValues.remove(QUARTER_OF_YEAR);
    return date.plusDays(doq);
}
 
Example 8
Source File: IsoFields.java    From desugar_jdk_libs with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    Long yearLong = fieldValues.get(YEAR);
    Long qoyLong = fieldValues.get(QUARTER_OF_YEAR);
    if (yearLong == null || qoyLong == null) {
        return null;
    }
    int y = YEAR.checkValidIntValue(yearLong);  // always validate
    long doq = fieldValues.get(DAY_OF_QUARTER);
    ensureIso(partialTemporal);
    LocalDate date;
    if (resolverStyle == ResolverStyle.LENIENT) {
        date = LocalDate.of(y, 1, 1).plusMonths(Math8.multiplyExact(Math8.subtractExact(qoyLong, 1), 3));
        doq = Math8.subtractExact(doq, 1);
    } else {
        int qoy = QUARTER_OF_YEAR.range().checkValidIntValue(qoyLong, QUARTER_OF_YEAR);  // validated
        date = LocalDate.of(y, ((qoy - 1) * 3) + 1, 1);
        if (doq < 1 || doq > 90) {
            if (resolverStyle == ResolverStyle.STRICT) {
                rangeRefinedBy(date).checkValidValue(doq, this);  // only allow exact range
            } else {  // SMART
                range().checkValidValue(doq, this);  // allow 1-92 rolling into next quarter
            }
        }
        doq--;
    }
    fieldValues.remove(this);
    fieldValues.remove(YEAR);
    fieldValues.remove(QUARTER_OF_YEAR);
    return date.plusDays(doq);
}
 
Example 9
Source File: AbstractChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
ChronoLocalDate resolveYAA(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR);
    if (resolverStyle == ResolverStyle.LENIENT) {
        long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1);
        long days = Math.subtractExact(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), 1);
        return dateYearDay(y, 1).plus(weeks, WEEKS).plus(days, DAYS);
    }
    int aw = range(ALIGNED_WEEK_OF_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), ALIGNED_WEEK_OF_YEAR);
    int ad = range(ALIGNED_DAY_OF_WEEK_IN_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), ALIGNED_DAY_OF_WEEK_IN_YEAR);
    ChronoLocalDate date = dateYearDay(y, 1).plus((aw - 1) * 7 + (ad - 1), DAYS);
    if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) {
        throw new DateTimeException("Strict mode rejected resolved date as it is in a different year");
    }
    return date;
}
 
Example 10
Source File: JapaneseChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override  // override for special Japanese behavior
ChronoLocalDate resolveYearOfEra(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    // validate era and year-of-era
    Long eraLong = fieldValues.get(ERA);
    JapaneseEra era = null;
    if (eraLong != null) {
        era = eraOf(range(ERA).checkValidIntValue(eraLong, ERA));  // always validated
    }
    Long yoeLong = fieldValues.get(YEAR_OF_ERA);
    int yoe = 0;
    if (yoeLong != null) {
        yoe = range(YEAR_OF_ERA).checkValidIntValue(yoeLong, YEAR_OF_ERA);  // always validated
    }
    // if only year-of-era and no year then invent era unless strict
    if (era == null && yoeLong != null && fieldValues.containsKey(YEAR) == false && resolverStyle != ResolverStyle.STRICT) {
        era = JapaneseEra.values()[JapaneseEra.values().length - 1];
    }
    // if both present, then try to create date
    if (yoeLong != null && era != null) {
        if (fieldValues.containsKey(MONTH_OF_YEAR)) {
            if (fieldValues.containsKey(DAY_OF_MONTH)) {
                return resolveYMD(era, yoe, fieldValues, resolverStyle);
            }
        }
        if (fieldValues.containsKey(DAY_OF_YEAR)) {
            return resolveYD(era, yoe, fieldValues, resolverStyle);
        }
    }
    return null;
}
 
Example 11
Source File: IsoChronology.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override  // override for enhanced behaviour
LocalDate resolveYearOfEra(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    Long yoeLong = fieldValues.remove(YEAR_OF_ERA);
    if (yoeLong != null) {
        if (resolverStyle != ResolverStyle.LENIENT) {
            YEAR_OF_ERA.checkValidValue(yoeLong);
        }
        Long era = fieldValues.remove(ERA);
        if (era == null) {
            Long year = fieldValues.get(YEAR);
            if (resolverStyle == ResolverStyle.STRICT) {
                // do not invent era if strict, but do cross-check with year
                if (year != null) {
                    addFieldValue(fieldValues, YEAR, (year > 0 ? yoeLong: Math.subtractExact(1, yoeLong)));
                } else {
                    // reinstate the field removed earlier, no cross-check issues
                    fieldValues.put(YEAR_OF_ERA, yoeLong);
                }
            } else {
                // invent era
                addFieldValue(fieldValues, YEAR, (year == null || year > 0 ? yoeLong: Math.subtractExact(1, yoeLong)));
            }
        } else if (era.longValue() == 1L) {
            addFieldValue(fieldValues, YEAR, yoeLong);
        } else if (era.longValue() == 0L) {
            addFieldValue(fieldValues, YEAR, Math.subtractExact(1, yoeLong));
        } else {
            throw new DateTimeException("Invalid value for era: " + era);
        }
    } else if (fieldValues.containsKey(ERA)) {
        ERA.checkValidValue(fieldValues.get(ERA));  // always validated
    }
    return null;
}
 
Example 12
Source File: IsoChronology.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override  // override for enhanced behaviour
LocalDate resolveYearOfEra(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    Long yoeLong = fieldValues.remove(YEAR_OF_ERA);
    if (yoeLong != null) {
        if (resolverStyle != ResolverStyle.LENIENT) {
            YEAR_OF_ERA.checkValidValue(yoeLong);
        }
        Long era = fieldValues.remove(ERA);
        if (era == null) {
            Long year = fieldValues.get(YEAR);
            if (resolverStyle == ResolverStyle.STRICT) {
                // do not invent era if strict, but do cross-check with year
                if (year != null) {
                    addFieldValue(fieldValues, YEAR, (year > 0 ? yoeLong: Math.subtractExact(1, yoeLong)));
                } else {
                    // reinstate the field removed earlier, no cross-check issues
                    fieldValues.put(YEAR_OF_ERA, yoeLong);
                }
            } else {
                // invent era
                addFieldValue(fieldValues, YEAR, (year == null || year > 0 ? yoeLong: Math.subtractExact(1, yoeLong)));
            }
        } else if (era.longValue() == 1L) {
            addFieldValue(fieldValues, YEAR, yoeLong);
        } else if (era.longValue() == 0L) {
            addFieldValue(fieldValues, YEAR, Math.subtractExact(1, yoeLong));
        } else {
            throw new DateTimeException("Invalid value for era: " + era);
        }
    } else if (fieldValues.containsKey(ERA)) {
        ERA.checkValidValue(fieldValues.get(ERA));  // always validated
    }
    return null;
}
 
Example 13
Source File: AbstractChronology.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
ChronoLocalDate resolveYAA(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR);
    if (resolverStyle == ResolverStyle.LENIENT) {
        long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1);
        long days = Math.subtractExact(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), 1);
        return dateYearDay(y, 1).plus(weeks, WEEKS).plus(days, DAYS);
    }
    int aw = range(ALIGNED_WEEK_OF_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), ALIGNED_WEEK_OF_YEAR);
    int ad = range(ALIGNED_DAY_OF_WEEK_IN_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), ALIGNED_DAY_OF_WEEK_IN_YEAR);
    ChronoLocalDate date = dateYearDay(y, 1).plus((aw - 1) * 7 + (ad - 1), DAYS);
    if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) {
        throw new DateTimeException("Strict mode rejected resolved date as it is in a different year");
    }
    return date;
}
 
Example 14
Source File: JapaneseChronology.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
@Override  // override for special Japanese behavior
ChronoLocalDate resolveYearOfEra(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
    // validate era and year-of-era
    Long eraLong = fieldValues.get(ERA);
    JapaneseEra era = null;
    if (eraLong != null) {
        era = eraOf(range(ERA).checkValidIntValue(eraLong, ERA));  // always validated
    }
    Long yoeLong = fieldValues.get(YEAR_OF_ERA);
    int yoe = 0;
    if (yoeLong != null) {
        yoe = range(YEAR_OF_ERA).checkValidIntValue(yoeLong, YEAR_OF_ERA);  // always validated
    }
    // if only year-of-era and no year then invent era unless strict
    if (era == null && yoeLong != null && fieldValues.containsKey(YEAR) == false && resolverStyle != ResolverStyle.STRICT) {
        era = JapaneseEra.values()[JapaneseEra.values().length - 1];
    }
    // if both present, then try to create date
    if (yoeLong != null && era != null) {
        if (fieldValues.containsKey(MONTH_OF_YEAR)) {
            if (fieldValues.containsKey(DAY_OF_MONTH)) {
                return resolveYMD(era, yoe, fieldValues, resolverStyle);
            }
        }
        if (fieldValues.containsKey(DAY_OF_YEAR)) {
            return resolveYD(era, yoe, fieldValues, resolverStyle);
        }
    }
    return null;
}
 
Example 15
Source File: IsoFields.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    Long yearLong = fieldValues.get(YEAR);
    Long qoyLong = fieldValues.get(QUARTER_OF_YEAR);
    if (yearLong == null || qoyLong == null) {
        return null;
    }
    int y = YEAR.checkValidIntValue(yearLong);  // always validate
    long doq = fieldValues.get(DAY_OF_QUARTER);
    ensureIso(partialTemporal);
    LocalDate date;
    if (resolverStyle == ResolverStyle.LENIENT) {
        date = LocalDate.of(y, 1, 1).plusMonths(Math.multiplyExact(Math.subtractExact(qoyLong, 1), 3));
        doq = Math.subtractExact(doq, 1);
    } else {
        int qoy = QUARTER_OF_YEAR.range().checkValidIntValue(qoyLong, QUARTER_OF_YEAR);  // validated
        date = LocalDate.of(y, ((qoy - 1) * 3) + 1, 1);
        if (doq < 1 || doq > 90) {
            if (resolverStyle == ResolverStyle.STRICT) {
                rangeRefinedBy(date).checkValidValue(doq, this);  // only allow exact range
            } else {  // SMART
                range().checkValidValue(doq, this);  // allow 1-92 rolling into next quarter
            }
        }
        doq--;
    }
    fieldValues.remove(this);
    fieldValues.remove(YEAR);
    fieldValues.remove(QUARTER_OF_YEAR);
    return date.plusDays(doq);
}
 
Example 16
Source File: TCKIsoChronology.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name = "resolve_yearOfEra")
Object[][] data_resolve_yearOfEra() {
    return new Object[][] {
            // era only
            {ResolverStyle.STRICT, -1, null, null, null, null},
            {ResolverStyle.SMART, -1, null, null, null, null},
            {ResolverStyle.LENIENT, -1, null, null, null, null},

            {ResolverStyle.STRICT, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.SMART, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.LENIENT, 0, null, null, ChronoField.ERA, 0},

            {ResolverStyle.STRICT, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.SMART, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.LENIENT, 1, null, null, ChronoField.ERA, 1},

            {ResolverStyle.STRICT, 2, null, null, null, null},
            {ResolverStyle.SMART, 2, null, null, null, null},
            {ResolverStyle.LENIENT, 2, null, null, null, null},

            // era and year-of-era
            {ResolverStyle.STRICT, -1, 2012, null, null, null},
            {ResolverStyle.SMART, -1, 2012, null, null, null},
            {ResolverStyle.LENIENT, -1, 2012, null, null, null},

            {ResolverStyle.STRICT, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, 0, 2012, null, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, 1, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, 2, 2012, null, null, null},
            {ResolverStyle.SMART, 2, 2012, null, null, null},
            {ResolverStyle.LENIENT, 2, 2012, null, null, null},

            // year-of-era only
            {ResolverStyle.STRICT, null, 2012, null, ChronoField.YEAR_OF_ERA, 2012},
            {ResolverStyle.SMART, null, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.SMART, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.LENIENT, null, Integer.MAX_VALUE, null, ChronoField.YEAR, Integer.MAX_VALUE},

            // year-of-era and year
            {ResolverStyle.STRICT, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, 2012, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, null, 2012, -2011, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, null, 2012, 2013, null, null},
            {ResolverStyle.SMART, null, 2012, 2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, 2013, null, null},

            {ResolverStyle.STRICT, null, 2012, -2013, null, null},
            {ResolverStyle.SMART, null, 2012, -2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, -2013, null, null},
    };
}
 
Example 17
Source File: TCKThaiBuddhistChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name = "resolve_yearOfEra")
Object[][] data_resolve_yearOfEra() {
    return new Object[][] {
            // era only
            {ResolverStyle.STRICT, -1, null, null, null, null},
            {ResolverStyle.SMART, -1, null, null, null, null},
            {ResolverStyle.LENIENT, -1, null, null, null, null},

            {ResolverStyle.STRICT, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.SMART, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.LENIENT, 0, null, null, ChronoField.ERA, 0},

            {ResolverStyle.STRICT, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.SMART, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.LENIENT, 1, null, null, ChronoField.ERA, 1},

            {ResolverStyle.STRICT, 2, null, null, null, null},
            {ResolverStyle.SMART, 2, null, null, null, null},
            {ResolverStyle.LENIENT, 2, null, null, null, null},

            // era and year-of-era
            {ResolverStyle.STRICT, -1, 2012, null, null, null},
            {ResolverStyle.SMART, -1, 2012, null, null, null},
            {ResolverStyle.LENIENT, -1, 2012, null, null, null},

            {ResolverStyle.STRICT, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, 0, 2012, null, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, 1, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, 2, 2012, null, null, null},
            {ResolverStyle.SMART, 2, 2012, null, null, null},
            {ResolverStyle.LENIENT, 2, 2012, null, null, null},

            // year-of-era only
            {ResolverStyle.STRICT, null, 2012, null, ChronoField.YEAR_OF_ERA, 2012},
            {ResolverStyle.SMART, null, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.SMART, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.LENIENT, null, Integer.MAX_VALUE, null, ChronoField.YEAR, Integer.MAX_VALUE},

            // year-of-era and year
            {ResolverStyle.STRICT, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, 2012, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, null, 2012, -2011, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, null, 2012, 2013, null, null},
            {ResolverStyle.SMART, null, 2012, 2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, 2013, null, null},

            {ResolverStyle.STRICT, null, 2012, -2013, null, null},
            {ResolverStyle.SMART, null, 2012, -2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, -2013, null, null},
    };
}
 
Example 18
Source File: TCKIsoChronology.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name = "resolve_yearOfEra")
Object[][] data_resolve_yearOfEra() {
    return new Object[][] {
            // era only
            {ResolverStyle.STRICT, -1, null, null, null, null},
            {ResolverStyle.SMART, -1, null, null, null, null},
            {ResolverStyle.LENIENT, -1, null, null, null, null},

            {ResolverStyle.STRICT, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.SMART, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.LENIENT, 0, null, null, ChronoField.ERA, 0},

            {ResolverStyle.STRICT, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.SMART, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.LENIENT, 1, null, null, ChronoField.ERA, 1},

            {ResolverStyle.STRICT, 2, null, null, null, null},
            {ResolverStyle.SMART, 2, null, null, null, null},
            {ResolverStyle.LENIENT, 2, null, null, null, null},

            // era and year-of-era
            {ResolverStyle.STRICT, -1, 2012, null, null, null},
            {ResolverStyle.SMART, -1, 2012, null, null, null},
            {ResolverStyle.LENIENT, -1, 2012, null, null, null},

            {ResolverStyle.STRICT, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, 0, 2012, null, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, 1, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, 2, 2012, null, null, null},
            {ResolverStyle.SMART, 2, 2012, null, null, null},
            {ResolverStyle.LENIENT, 2, 2012, null, null, null},

            // year-of-era only
            {ResolverStyle.STRICT, null, 2012, null, ChronoField.YEAR_OF_ERA, 2012},
            {ResolverStyle.SMART, null, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.SMART, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.LENIENT, null, Integer.MAX_VALUE, null, ChronoField.YEAR, Integer.MAX_VALUE},

            // year-of-era and year
            {ResolverStyle.STRICT, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, 2012, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, null, 2012, -2011, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, null, 2012, 2013, null, null},
            {ResolverStyle.SMART, null, 2012, 2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, 2013, null, null},

            {ResolverStyle.STRICT, null, 2012, -2013, null, null},
            {ResolverStyle.SMART, null, 2012, -2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, -2013, null, null},
    };
}
 
Example 19
Source File: TCKMinguoChronology.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name = "resolve_yearOfEra")
Object[][] data_resolve_yearOfEra() {
    return new Object[][] {
            // era only
            {ResolverStyle.STRICT, -1, null, null, null, null},
            {ResolverStyle.SMART, -1, null, null, null, null},
            {ResolverStyle.LENIENT, -1, null, null, null, null},

            {ResolverStyle.STRICT, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.SMART, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.LENIENT, 0, null, null, ChronoField.ERA, 0},

            {ResolverStyle.STRICT, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.SMART, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.LENIENT, 1, null, null, ChronoField.ERA, 1},

            {ResolverStyle.STRICT, 2, null, null, null, null},
            {ResolverStyle.SMART, 2, null, null, null, null},
            {ResolverStyle.LENIENT, 2, null, null, null, null},

            // era and year-of-era
            {ResolverStyle.STRICT, -1, 2012, null, null, null},
            {ResolverStyle.SMART, -1, 2012, null, null, null},
            {ResolverStyle.LENIENT, -1, 2012, null, null, null},

            {ResolverStyle.STRICT, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, 0, 2012, null, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, 1, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, 2, 2012, null, null, null},
            {ResolverStyle.SMART, 2, 2012, null, null, null},
            {ResolverStyle.LENIENT, 2, 2012, null, null, null},

            // year-of-era only
            {ResolverStyle.STRICT, null, 2012, null, ChronoField.YEAR_OF_ERA, 2012},
            {ResolverStyle.SMART, null, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.SMART, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.LENIENT, null, Integer.MAX_VALUE, null, ChronoField.YEAR, Integer.MAX_VALUE},

            // year-of-era and year
            {ResolverStyle.STRICT, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, 2012, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, null, 2012, -2011, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, null, 2012, 2013, null, null},
            {ResolverStyle.SMART, null, 2012, 2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, 2013, null, null},

            {ResolverStyle.STRICT, null, 2012, -2013, null, null},
            {ResolverStyle.SMART, null, 2012, -2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, -2013, null, null},
    };
}
 
Example 20
Source File: TCKThaiBuddhistChronology.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name = "resolve_yearOfEra")
Object[][] data_resolve_yearOfEra() {
    return new Object[][] {
            // era only
            {ResolverStyle.STRICT, -1, null, null, null, null},
            {ResolverStyle.SMART, -1, null, null, null, null},
            {ResolverStyle.LENIENT, -1, null, null, null, null},

            {ResolverStyle.STRICT, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.SMART, 0, null, null, ChronoField.ERA, 0},
            {ResolverStyle.LENIENT, 0, null, null, ChronoField.ERA, 0},

            {ResolverStyle.STRICT, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.SMART, 1, null, null, ChronoField.ERA, 1},
            {ResolverStyle.LENIENT, 1, null, null, ChronoField.ERA, 1},

            {ResolverStyle.STRICT, 2, null, null, null, null},
            {ResolverStyle.SMART, 2, null, null, null, null},
            {ResolverStyle.LENIENT, 2, null, null, null, null},

            // era and year-of-era
            {ResolverStyle.STRICT, -1, 2012, null, null, null},
            {ResolverStyle.SMART, -1, 2012, null, null, null},
            {ResolverStyle.LENIENT, -1, 2012, null, null, null},

            {ResolverStyle.STRICT, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, 0, 2012, null, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, 0, 2012, null, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, 1, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, 1, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, 2, 2012, null, null, null},
            {ResolverStyle.SMART, 2, 2012, null, null, null},
            {ResolverStyle.LENIENT, 2, 2012, null, null, null},

            // year-of-era only
            {ResolverStyle.STRICT, null, 2012, null, ChronoField.YEAR_OF_ERA, 2012},
            {ResolverStyle.SMART, null, 2012, null, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, null, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.SMART, null, Integer.MAX_VALUE, null, null, null},
            {ResolverStyle.LENIENT, null, Integer.MAX_VALUE, null, ChronoField.YEAR, Integer.MAX_VALUE},

            // year-of-era and year
            {ResolverStyle.STRICT, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.SMART, null, 2012, 2012, ChronoField.YEAR, 2012},
            {ResolverStyle.LENIENT, null, 2012, 2012, ChronoField.YEAR, 2012},

            {ResolverStyle.STRICT, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.SMART, null, 2012, -2011, ChronoField.YEAR, -2011},
            {ResolverStyle.LENIENT, null, 2012, -2011, ChronoField.YEAR, -2011},

            {ResolverStyle.STRICT, null, 2012, 2013, null, null},
            {ResolverStyle.SMART, null, 2012, 2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, 2013, null, null},

            {ResolverStyle.STRICT, null, 2012, -2013, null, null},
            {ResolverStyle.SMART, null, 2012, -2013, null, null},
            {ResolverStyle.LENIENT, null, 2012, -2013, null, null},
    };
}