Java LocalDate Calculate getWeekOfTheYear(final LocalDate dateOfYear)

Here you can find the source of getWeekOfTheYear(final LocalDate dateOfYear)

Description

Returns the numerical week of the year given a date per the ISO 8601 standard.

License

Open Source License

Parameter

Parameter Description
dateOfYear the base date to work from

Return

the week of the year

Declaration

public static int getWeekOfTheYear(final LocalDate dateOfYear) 

Method Source Code

//package com.java2s;
/*//from  ww  w  .j  av a 2  s .co m
 * jGnash, a personal finance application
 * Copyright (C) 2001-2019 Craig Cavanaugh
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.time.LocalDate;

import java.time.temporal.WeekFields;

public class Main {
    /**
     * Returns the numerical week of the year given a date per the ISO 8601 standard.
     *
     * @param dateOfYear the base date to work from
     * @return the week of the year
     */
    public static int getWeekOfTheYear(final LocalDate dateOfYear) {
        return dateOfYear.get(WeekFields.ISO.weekOfWeekBasedYear());
    }
}

Related

  1. getMax(@Nonnull final LocalDate aDate1, @Nonnull final LocalDate aDate2)
  2. getNextNoWeekedDay(LocalDate today)
  3. getQuarterBounds(final LocalDate date)
  4. getTimeDifferenceInDays(LocalDate to)
  5. getTodayAsLocalDate()
  6. getYearMonth(LocalDate localDate)
  7. isActual(LocalDate before, LocalDate after)
  8. isAnyLocalDate(Object obj)
  9. isBankHoliday(List bankHolidays, LocalDate date)