Java examples for java.time:LocalDate
get Month End LocalDate
//package com.java2s; import java.time.LocalDate; import java.time.temporal.ChronoUnit; public class Main { public static LocalDate getMonthEndLocalDate(LocalDate targetLocalDate, int baseDate) { LocalDate endLocalDate = targetLocalDate.withDayOfMonth(baseDate) .minusDays(1);/* w w w. j av a2s . com*/ return getEndLocalDate(targetLocalDate, endLocalDate, baseDate, ChronoUnit.MONTHS); } private static LocalDate getEndLocalDate(LocalDate targetLocalDate, LocalDate endLocalDate, int baseDate, ChronoUnit chronoUnit) { if (targetLocalDate.getMonth() == endLocalDate.getMonth() && targetLocalDate.getDayOfMonth() >= baseDate) { endLocalDate = endLocalDate.plus(1, chronoUnit); } return endLocalDate; } }