微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java.time.format.ResolverStyle的实例源码

项目:openjdk-jdk10    文件IsoChronology.java   
@Override  // override for performance
LocalDate resolveYMD(Map <TemporalField,Long> fieldValues,ResolverStyle resolverStyle) {
    int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR));
    if (resolverStyle == ResolverStyle.LENIENT) {
        long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR),1);
        long days = Math.subtractExact(fieldValues.remove(DAY_OF_MONTH),1);
        return LocalDate.of(y,1,1).plusMonths(months).plusDays(days);
    }
    int moy = MONTH_OF_YEAR.checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR));
    int dom = DAY_OF_MONTH.checkValidIntValue(fieldValues.remove(DAY_OF_MONTH));
    if (resolverStyle == ResolverStyle.SMART) {  // prevIoUs valid
        if (moy == 4 || moy == 6 || moy == 9 || moy == 11) {
            dom = Math.min(dom,30);
        } else if (moy == 2) {
            dom = Math.min(dom,Month.FEBRUARY.length(Year.isLeap(y)));

        }
    }
    return LocalDate.of(y,moy,dom);
}
项目:Openjsharp    文件IsoChronology.java   
@Override  // override for performance
LocalDate resolveYMD(Map <TemporalField,dom);
}
项目:openjdk-jdk10    文件AbstractChronology.java   
ChronoLocalDate resolveYMD(Map<TemporalField,ResolverStyle resolverStyle) {
    int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR),YEAR);
    if (resolverStyle == ResolverStyle.LENIENT) {
        long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR),1);
        return date(y,1).plus(months,MONTHS).plus(days,DAYS);
    }
    int moy = range(MONTH_OF_YEAR).checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR),MONTH_OF_YEAR);
    ValueRange domrange = range(DAY_OF_MONTH);
    int dom = domrange.checkValidIntValue(fieldValues.remove(DAY_OF_MONTH),DAY_OF_MONTH);
    if (resolverStyle == ResolverStyle.SMART) {  // prevIoUs valid
        try {
            return date(y,dom);
        } catch (DateTimeException ex) {
            return date(y,1).with(TemporalAdjusters.lastDayOfMonth());
        }
    }
    return date(y,dom);
}
项目:openjdk-jdk10    文件TCKDateTimeParseResolver.java   
@Test(dataProvider="resolveFourToTime")
public void test_resolveFourToDateTime(ResolverStyle style,long hour,long min,long sec,long nano,LocalTime expectedTime,Period excessperiod) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .parseDefaulting(YEAR,2012).parseDefaulting(MONTH_OF_YEAR,6).parseDefaulting(DAY_OF_MONTH,30)
            .parseDefaulting(HOUR_OF_DAY,hour)
            .parseDefaulting(MINUTE_OF_HOUR,min)
            .parseDefaulting(SECOND_OF_MINUTE,sec)
            .parseDefaulting(NANO_OF_SECOND,nano).toFormatter();

    ResolverStyle[] styles = (style != null ? new ResolverStyle[] {style} : ResolverStyle.values());
    if (expectedTime != null && excessperiod != null) {
        LocalDate expectedDate = LocalDate.of(2012,6,30).plus(excessperiod);
        for (ResolverStyle s : styles) {
            TemporalAccessor accessor = f.withResolverStyle(s).parse("");
            assertEquals(accessor.query(TemporalQueries.localDate()),expectedDate,"ResolverStyle: " + s);
            assertEquals(accessor.query(TemporalQueries.localTime()),expectedTime,"ResolverStyle: " + s);
            assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()),Period.ZERO,"ResolverStyle: " + s);
        }
    }
}
项目:openjdk-jdk10    文件TCKIsoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y,int m,int w,int d,LocalDate expected,boolean smart,boolean strict) {
    Map<TemporalField,Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR,(long) y);
    fieldValues.put(ChronoField.MONTH_OF_YEAR,(long) m);
    fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH,(long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH,(long) d);
    if (strict) {
        LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues,ResolverStyle.STRICT);
        assertEquals(date,expected);
        assertEquals(fieldValues.size(),0);
    } else {
        try {
            IsoChronology.INSTANCE.resolveDate(fieldValues,ResolverStyle.STRICT);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKThaiBuddhistChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y,ThaiBuddhistDate expected,Object smart,(long) m);
    fieldValues.put(ChronoField.DAY_OF_MONTH,(long) d);
    if (strict) {
        ThaiBuddhistDate date = ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues,0);
    } else {
        try {
            ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues,ResolverStyle.STRICT);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKIsoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(int y,(long) d);
    if (smart) {
        LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues,ResolverStyle.SMART);
        assertEquals(date,ResolverStyle.SMART);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKIsoChronology.java   
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style,Integer e,Integer yoe,Integer y,ChronoField field,Integer expected) {
    Map<TemporalField,Long> fieldValues = new HashMap<>();
    if (e != null) {
        fieldValues.put(ChronoField.ERA,(long) e);
    }
    if (yoe != null) {
        fieldValues.put(ChronoField.YEAR_OF_ERA,(long) yoe);
    }
    if (y != null) {
        fieldValues.put(ChronoField.YEAR,(long) y);
    }
    if (field != null) {
        LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues,style);
        assertEquals(date,null);
        assertEquals(fieldValues.get(field),(Long) expected.longValue());
        assertEquals(fieldValues.size(),1);
    } else {
        try {
            IsoChronology.INSTANCE.resolveDate(fieldValues,style);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKDateTimeParseResolver.java   
@Test(dataProvider="resolveSecondOfDay")
public void test_resolveSecondOfDay(ResolverStyle style,long value,Integer expectedSecond,int expectedDays) {
    String str = Long.toString(value);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(SECOND_OF_DAY).toFormatter();

    if (expectedSecond != null) {
        TemporalAccessor accessor = f.withResolverStyle(style).parse(str);
        assertEquals(accessor.query(TemporalQueries.localDate()),null);
        assertEquals(accessor.query(TemporalQueries.localTime()),LocalTime.ofSecondOfDay(expectedSecond));
        assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()),Period.ofDays(expectedDays));
    } else {
        try {
            f.withResolverStyle(style).parse(str);
            fail();
        } catch (DateTimeParseException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKThaiBuddhistChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y,ResolverStyle.STRICT);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKIsoChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y,ResolverStyle.STRICT);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKIsoFields.java   
@Test(dataProvider = "parseLenientWeek")
public void test_parse_parseLenientWeek_SMART(String str,boolean smart) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':')
            .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':')
            .appendValue(DAY_OF_WEEK)
            .toFormatter().withResolverStyle(ResolverStyle.SMART);
    if (smart) {
        LocalDate parsed = LocalDate.parse(str,f);
        assertEquals(parsed,expected);
    } else {
        try {
            LocalDate.parse(str,f);
            fail("Should have Failed");
        } catch (DateTimeParseException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y,MinguoDate expected,(long) y);
    fieldValues.put(ChronoField.DAY_OF_YEAR,(long) d);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues,0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues,ResolverStyle.SMART);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKThaiBuddhistChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y,(long) d);
    if (smart) {
        ThaiBuddhistDate date = ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues,ResolverStyle.SMART);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKThaiBuddhistChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y,ResolverStyle.SMART);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKDateTimeParseResolver.java   
@Test(dataProvider="resolveFourToTime")
public void test_resolveThreetoTime(ResolverStyle style,Period excessperiod) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .parseDefaulting(HOUR_OF_DAY,sec).toFormatter();

    ResolverStyle[] styles = (style != null ? new ResolverStyle[] {style} : ResolverStyle.values());
    for (ResolverStyle s : styles) {
        if (expectedTime != null) {
            TemporalAccessor accessor = f.withResolverStyle(s).parse("");
            assertEquals(accessor.query(TemporalQueries.localDate()),null,expectedTime.minusNanos(nano),excessperiod,"ResolverStyle: " + s);
        } else {
            try {
                f.withResolverStyle(style).parse("");
                fail();
            } catch (DateTimeParseException ex) {
                // expected
            }
        }
    }
}
项目:jdk8u-jdk    文件TCKDateTimeParseResolver.java   
@Test(dataProvider="resolveFourToTime")
public void test_resolveFourToDateTime(ResolverStyle style,"ResolverStyle: " + s);
        }
    }
}
项目:jdk8u-jdk    文件TCKDateTimeParseResolver.java   
@Test(dataProvider="resolveSecondOfDay")
public void test_resolveSecondOfDay(ResolverStyle style,Period.ofDays(expectedDays));
    } else {
        try {
            f.withResolverStyle(style).parse(str);
            fail();
        } catch (DateTimeParseException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKThaiBuddhistChronology.java   
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style,(long) y);
    }
    if (field != null) {
        ThaiBuddhistDate date = ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues,1);
    } else {
        try {
            ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues,style);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKDateTimeParseResolver.java   
@Test(dataProvider="resolveClockHourOfDay")
public void test_resolveClockHourOfDay(ResolverStyle style,Integer expectedHour,int expectedDays) {
    String str = Long.toString(value);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(CLOCK_HOUR_OF_DAY).toFormatter();

    if (expectedHour != null) {
        TemporalAccessor accessor = f.withResolverStyle(style).parse(str);
        assertEquals(accessor.query(TemporalQueries.localDate()),LocalTime.of(expectedHour,0));
        assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()),Period.ofDays(expectedDays));
    } else {
        try {
            f.withResolverStyle(style).parse(str);
            fail();
        } catch (DateTimeParseException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKDateTimeParseResolver.java   
@Test(dataProvider="resolveClockHourOfAmPm")
public void test_resolveClockHourOfAmPm(ResolverStyle style,Integer expectedValue) {
    String str = Long.toString(value);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(CLOCK_HOUR_OF_AMPM).toFormatter();

    if (expectedValue != null) {
        TemporalAccessor accessor = f.withResolverStyle(style).parse(str);
        assertEquals(accessor.query(TemporalQueries.localDate()),null);
        assertEquals(accessor.isSupported(CLOCK_HOUR_OF_AMPM),false);
        assertEquals(accessor.isSupported(HOUR_OF_AMPM),true);
        assertEquals(accessor.getLong(HOUR_OF_AMPM),expectedValue.longValue());
    } else {
        try {
            f.withResolverStyle(style).parse(str);
            fail();
        } catch (DateTimeParseException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKDateTimeParseResolver.java   
@Test(dataProvider="resolveAmPm")
public void test_resolveAmPm(ResolverStyle style,Integer expectedValue) {
    String str = Long.toString(value);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(AMPM_OF_DAY).toFormatter();

    if (expectedValue != null) {
        TemporalAccessor accessor = f.withResolverStyle(style).parse(str);
        assertEquals(accessor.query(TemporalQueries.localDate()),null);
        assertEquals(accessor.isSupported(AMPM_OF_DAY),true);
        assertEquals(accessor.getLong(AMPM_OF_DAY),expectedValue.longValue());
    } else {
        try {
            f.withResolverStyle(style).parse(str);
            fail();
        } catch (DateTimeParseException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKIsoChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y,ResolverStyle.STRICT);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKJapaneseChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y,JapaneseDate expected,(long) d);
    if (strict) {
        JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues,0);
    } else {
        try {
            JapaneseChronology.INSTANCE.resolveDate(fieldValues,ResolverStyle.STRICT);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y,(long) d);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues,ResolverStyle.STRICT);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y,ResolverStyle.SMART);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKIsoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y,ResolverStyle.SMART);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKJapaneseChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y,ResolverStyle.STRICT);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style,(long) y);
    }
    if (field != null) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues,1);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues,style);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件TCKJapaneseChronology.java   
@Test(dataProvider = "resolve_eymd")
public void test_resolve_eymd(ResolverStyle style,JapaneseEra era,int yoe,JapaneseDate expected) {
    Map<TemporalField,Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.ERA,(long) era.getValue());
    fieldValues.put(ChronoField.YEAR_OF_ERA,(long) yoe);
    fieldValues.put(ChronoField.MONTH_OF_YEAR,(long) d);
    if (expected != null) {
        JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues,style);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件TCKJapaneseChronology.java   
@Test(dataProvider = "resolve_eymd")
public void test_resolve_eymd(ResolverStyle style,style);
            fail("Should have Failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:Openjsharp    文件IsoFields.java   
@Override
public ChronoLocalDate resolve(
        Map<TemporalField,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).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);
}
项目:Openjsharp    文件JulianFields.java   
@Override
public ChronoLocalDate resolve(
        Map<TemporalField,ResolverStyle resolverStyle) {
    long value = fieldValues.remove(this);
    Chronology chrono = Chronology.from(partialTemporal);
    if (resolverStyle == ResolverStyle.LENIENT) {
        return chrono.dateEpochDay(Math.subtractExact(value,offset));
    }
    range().checkValidValue(value,this);
    return chrono.dateEpochDay(value - offset);
}
项目:Openjsharp    文件JapaneseChronology.java   
private ChronoLocalDate resolveYD(JapaneseEra era,Map <TemporalField,ResolverStyle resolverStyle) {
    fieldValues.remove(ERA);
    fieldValues.remove(YEAR_OF_ERA);
    if (resolverStyle == ResolverStyle.LENIENT) {
        int y = prolepticYearLenient(era,yoe);
        long days = Math.subtractExact(fieldValues.remove(DAY_OF_YEAR),1);
        return dateYearDay(y,1).plus(days,DAYS);
    }
    int doy = range(DAY_OF_YEAR).checkValidIntValue(fieldValues.remove(DAY_OF_YEAR),DAY_OF_YEAR);
    return dateYearDay(era,yoe,doy);  // smart is same as strict
}
项目:jdk8u-jdk    文件TCKHijrahChronology.java   
@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraAndYearOnly_valid(ResolverStyle style,HijrahEra era) {
    Map<TemporalField,(long) era.getValue());
    fieldValues.put(ChronoField.YEAR,1343L);
    HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues,style);
    assertEquals(date,null);
    assertEquals(fieldValues.get(ChronoField.ERA),(Long) (long) era.getValue());
    assertEquals(fieldValues.get(ChronoField.YEAR),(Long) 1343L);
    assertEquals(fieldValues.size(),2);
}
项目:Openjsharp    文件AbstractChronology.java   
void resolveProlepticMonth(Map<TemporalField,ResolverStyle resolverStyle) {
    Long pMonth = fieldValues.remove(PROLEPTIC_MONTH);
    if (pMonth != null) {
        if (resolverStyle != ResolverStyle.LENIENT) {
            PROLEPTIC_MONTH.checkValidValue(pMonth);
        }
        // first day-of-month is likely to be safest for setting proleptic-month
        // cannot add to year zero,as not all chronologies have a year zero
        ChronoLocalDate chronoDate = dateNow()
                .with(DAY_OF_MONTH,1).with(PROLEPTIC_MONTH,pMonth);
        addFieldValue(fieldValues,MONTH_OF_YEAR,chronoDate.get(MONTH_OF_YEAR));
        addFieldValue(fieldValues,YEAR,chronoDate.get(YEAR));
    }
}
项目:Openjsharp    文件AbstractChronology.java   
ChronoLocalDate resolveYD(Map<TemporalField,YEAR);
    if (resolverStyle == ResolverStyle.LENIENT) {
        long days = Math.subtractExact(fieldValues.remove(DAY_OF_YEAR),DAY_OF_YEAR);
    return dateYearDay(y,doy);  // smart is same as strict
}
项目:jdk8u-jdk    文件IsoFields.java   
@Override
public ChronoLocalDate resolve(
        Map<TemporalField,this);  // allow 1-92 rolling into next quarter
            }
        }
        doq--;
    }
    fieldValues.remove(this);
    fieldValues.remove(YEAR);
    fieldValues.remove(QUARTER_OF_YEAR);
    return date.plusDays(doq);
}
项目:openjdk-jdk10    文件AbstractChronology.java   
ChronoLocalDate resolveYAA(Map<TemporalField,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).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;
}
项目:jdk8u-jdk    文件IsoChronology.java   
@Override  // override for enhanced behavIoUr
LocalDate resolveYearOfEra(Map<TemporalField,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 > 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 == null || year > 0 ? yoeLong: Math.subtractExact(1,yoeLong)));
            }
        } else if (era.longValue() == 1L) {
            addFieldValue(fieldValues,yoeLong);
        } else if (era.longValue() == 0L) {
            addFieldValue(fieldValues,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;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。