Here you can find the source of getFirstDayOfTheMonth(final LocalDate date)
Parameter | Description |
---|---|
date | the base date to work from |
public static LocalDate getFirstDayOfTheMonth(final LocalDate date)
//package com.java2s; /*/*from www . j ava 2 s .c om*/ * 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.TemporalAdjusters; public class Main { /** * Returns a leveled date representing the first day of the month based on a * specified date. * * @param date the base date to work from * @return The last day of the month and year specified */ public static LocalDate getFirstDayOfTheMonth(final LocalDate date) { return date.with(TemporalAdjusters.firstDayOfMonth()); } /** * Returns a date representing the first day of the month. * * @param month The month (index starts at 1) * @param year The year (index starts at 1) * @return The last day of the month and year specified */ private static LocalDate getFirstDayOfTheMonth(final int month, final int year) { return LocalDate.of(year, month, 1); } }