Java examples for java.time:LocalDate
get Year Start LocalDate
//package com.java2s; import java.time.LocalDate; import java.time.temporal.ChronoUnit; public class Main { public static LocalDate getYearStartLocalDate( LocalDate targetLocalDate, int baseDate) { LocalDate startLocalDate = targetLocalDate.withMonth(1) .withDayOfMonth(baseDate); return getStartLocalDate(targetLocalDate, startLocalDate, baseDate, ChronoUnit.YEARS); }/* ww w. j a v a 2 s . c o m*/ private static LocalDate getStartLocalDate(LocalDate targetLocalDate, LocalDate startLocalDate, int baseDate, ChronoUnit chronoUnit) { if (targetLocalDate.getMonth() == startLocalDate.getMonth() && targetLocalDate.getDayOfMonth() < baseDate) { startLocalDate = startLocalDate.minus(1, chronoUnit); } return startLocalDate; } }