ZonedDateTime with(TemporalAdjuster adjuster)
returns an adjusted copy of this date-time.
with
has the following syntax.
public ZonedDateTime with(TemporalAdjuster adjuster)
The following example shows how to use with
.
import java.time.ZonedDateTime; import java.time.temporal.TemporalAdjusters; //from ww w. ja va 2s. co m public class Main { public static void main(String[] args) { ZonedDateTime dateTime =ZonedDateTime.now(); dateTime = dateTime.with(TemporalAdjusters.firstDayOfMonth()); System.out.println(dateTime); } }
The code above generates the following result.