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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Year atMonth(Month month) method in Java
- LocalDate adjustInto() method in Java
- Instant adjustInto() method in Java with Example
- OffsetDateTime adjustInto() method in Java with examples
- ChronoLocalDate adjustInto() method in Java with Examples
- LocalTime adjustInto() method in Java with Examples
- MonthDay adjustInto() method in Java with Examples
- OffsetTime adjustInto() method in Java with examples
- DayOfWeek adjustInto() method in Java with Examples
- Year adjustInto() Method in Java with Examples
- ChronoLocalDateTime adjustInto() method in Java with Examples
- ZoneOffset adjustInto(Temporal) method in Java with Examples
- Month from() method in Java
- Month plus() method in Java
- Month get() method in Java
- Month of() method in Java
- Month getLong() method in Java
- Month maxLength() method in Java
- Month minus() method in Java
- Month getDisplayName() 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 email@example.com. 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.