Example usage for java.time.temporal ChronoField ALIGNED_WEEK_OF_YEAR

List of usage examples for java.time.temporal ChronoField ALIGNED_WEEK_OF_YEAR

Introduction

In this page you can find the example usage for java.time.temporal ChronoField ALIGNED_WEEK_OF_YEAR.

Prototype

ChronoField ALIGNED_WEEK_OF_YEAR

To view the source code for java.time.temporal ChronoField ALIGNED_WEEK_OF_YEAR.

Click Source Link

Document

The aligned week within a year.

Usage

From source file:org.silverpeas.core.calendar.Recurrence.java

private Temporal computeDateForYearlyFrequencyFrom(final Temporal source, DayOfWeekOccurrence dayOfWeek) {
    final int lastDayOfYear = 31;
    Temporal current = source;/*from w w w . j a  v a 2 s  .  co  m*/
    if (dayOfWeek.nth() > 1) {
        current = current.with(ChronoField.ALIGNED_WEEK_OF_YEAR, dayOfWeek.nth());
    } else if (dayOfWeek.nth() < 0) {
        current = current.with(MonthDay.of(Month.DECEMBER, lastDayOfYear))
                .plus(dayOfWeek.nth(), ChronoUnit.WEEKS).with(dayOfWeek.dayOfWeek());
    }
    return current;
}