The adjustInto() method of java.time.Month ENUM is an in-built function in Java which takes a Temporal object specifying a date and returns a new Temporal object of the same observable type as the input with the month replaced with this month-of-year.
public Temporal adjustInto(Temporal temporal)
Temporal newLocalDate = Month.ANYMONTH.adjustInto(Temporal temporal)
Parameters: This method takes temporal as parameter where:
- temporal – is the specified date to be adjusted.
- ANYMONTH – is the specified month to which the date is to be adjusted, e.g., JANUARY, FEBRUARY, etc.
- newLocalDate – is the modified date.
Return Value: The function returns an adjusted Temporal object which is the date adjusted according to specified Month.
- DateTimeException: This method throws this exception if it is not possible to make the adjustment.
- ArithmeticException: This exception is thrown if numeric overflow occurs.
Below programs illustrate the above method:
1947-08-15 which is AUGUST 1947-01-15 which is JANUARY
2019-03-18 which is MARCH 2019-12-18 which is DECEMBER
- Year atMonth(Month month) method in Java
- Instant adjustInto() method in Java with Example
- LocalDate adjustInto() method in Java
- ChronoLocalDateTime adjustInto() method in Java with Examples
- MonthDay adjustInto() method in Java with Examples
- LocalTime adjustInto() method in Java with Examples
- ChronoLocalDate adjustInto() method in Java with Examples
- DayOfWeek adjustInto() method in Java with Examples
- OffsetDateTime adjustInto() method in Java with examples
- OffsetTime adjustInto() method in Java with examples
- Year adjustInto() Method in Java with Examples
- ZoneOffset adjustInto(Temporal) method in Java with Examples
- Month of() method in Java
- Month from() method in Java
- Month get() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.