OffsetDateTime withDayOfMonth(int dayOfMonth) example
Description
OffsetDateTime withDayOfMonth(int dayOfMonth)
returns a copy
of this OffsetDateTime with the day-of-month altered.
Syntax
withDayOfMonth
has the following syntax.
public OffsetDateTime withDayOfMonth(int dayOfMonth)
Example
The following example shows how to use withDayOfMonth
.
import java.time.OffsetDateTime;
//from ww w .j a v a 2 s. com
public class Main {
public static void main(String[] args) {
OffsetDateTime o = OffsetDateTime.now();
OffsetDateTime d = o.withDayOfMonth(1);
System.out.println(d);
}
}
The code above generates the following result.