Here you can find the source of getWeekOfTheYear(final LocalDate dateOfYear)
Parameter | Description |
---|---|
dateOfYear | the base date to work from |
public static int getWeekOfTheYear(final LocalDate dateOfYear)
//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()); } }