Java Code Examples for java.time.chrono.ChronoLocalDate#lengthOfYear()

The following examples show how to use java.time.chrono.ChronoLocalDate#lengthOfYear() . 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: WeekFields.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 2
Source File: WeekFields.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 3
Source File: WeekFields.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 4
Source File: WeekFields.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 5
Source File: WeekFields.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 6
Source File: WeekFields.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 7
Source File: WeekFields.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 8
Source File: WeekFields.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 9
Source File: WeekFields.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 10
Source File: WeekFields.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 11
Source File: WeekFields.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 12
Source File: WeekFields.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 13
Source File: WeekFields.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 14
Source File: WeekFields.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 15
Source File: WeekFields.java    From desugar_jdk_libs with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 16
Source File: WeekFields.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 17
Source File: WeekFields.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 18
Source File: WeekFields.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}
 
Example 19
Source File: WeekFields.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a new week-based-year date of the Chronology, year, week-of-year,
 * and dow of week.
 * @param chrono The chronology of the new date
 * @param yowby the year of the week-based-year
 * @param wowby the week of the week-based-year
 * @param dow the day of the week
 * @return a ChronoLocalDate for the requested year, week of year, and day of week
 */
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
        int yowby, int wowby, int dow) {
    ChronoLocalDate date = chrono.date(yowby, 1, 1);
    int ldow = localizedDayOfWeek(date);
    int offset = startOfWeekOffset(1, ldow);

    // Clamp the week of year to keep it in the same year
    int yearLen = date.lengthOfYear();
    int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
    wowby = Math.min(wowby, newYearWeek - 1);

    int days = -offset + (dow - 1) + (wowby - 1) * 7;
    return date.plus(days, DAYS);
}