LocalDate with(TemporalAdjuster adjuster)
returns an adjusted copy of this date.
with
has the following syntax.
public LocalDate with(TemporalAdjuster adjuster)
The following example shows how to use with
.
import java.time.LocalDate; import java.time.temporal.TemporalAdjusters; //from ww w . j a va2s.c o m public class Main { public static void main(String[] args) { LocalDate a = LocalDate.of(2014, 6, 30); LocalDate b = a.with(TemporalAdjusters.firstDayOfMonth()); System.out.println(b); } }
The code above generates the following result.