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