Java LocalDate Calculate getYearMonth(LocalDate localDate)

Here you can find the source of getYearMonth(LocalDate localDate)

Description

Gets the YearMonth of a specified LocalDate .

License

CDDL license

Parameter

Parameter Description
localDate a LocalDate

Return

the of a specified

Declaration

public static YearMonth getYearMonth(LocalDate localDate) 

Method Source Code


//package com.java2s;
/*//from   w  w w  .java2 s  . co  m
 *         COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Notice
 *
 * The contents of this file are subject to the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.opensource.org/licenses/cddl1.txt
 *
 * The Original Code is SoftSmithy Utility Library. The Initial Developer of the
 * Original Code is Florian Brunner (Sourceforge.net user: puce). All Rights Reserved.
 *
 * Contributor(s): .
 */

import java.time.LocalDate;
import java.time.YearMonth;

public class Main {
    /**
     * Gets the {@link YearMonth} of a specified {@link LocalDate}.
     *
     * @param localDate a {@link LocalDate}
     * @return the {@link YearMonth} of a specified {@link LocalDate}
     */
    public static YearMonth getYearMonth(LocalDate localDate) {
        return localDate != null ? YearMonth.of(localDate.getYear(), localDate.getMonth()) : null;
    }
}

Related

  1. getNextNoWeekedDay(LocalDate today)
  2. getQuarterBounds(final LocalDate date)
  3. getTimeDifferenceInDays(LocalDate to)
  4. getTodayAsLocalDate()
  5. getWeekOfTheYear(final LocalDate dateOfYear)
  6. isActual(LocalDate before, LocalDate after)
  7. isAnyLocalDate(Object obj)
  8. isBankHoliday(List bankHolidays, LocalDate date)
  9. isDayOfWeek(LocalDate d, DayOfWeek dow)