Java examples for java.time:Week
Returns LocalDate date of the Sunday of week to which provided date belongs to.
//package com.java2s; import java.time.DayOfWeek; import java.time.LocalDate; public class Main { /**/*ww w . java 2 s . c o m*/ * Returns {@link LocalDate} date of the Sunday of week to which provided {@code date} belongs to. */ public static LocalDate getWeekEnd(LocalDate date) { int daysToSunday = DayOfWeek.SUNDAY.getValue() - date.getDayOfWeek().getValue(); return date.plusDays(daysToSunday); } }