MonthDay adjustInto() method in Java with Examples Last Updated : 01 May, 2023 Comments Improve Suggest changes Like Article Like Report adjustInto() method of the MonthDay class used to adjusts the passed temporal object to have this MonthYear on which this method is applied.This instance is immutable and unaffected by this method call. Syntax: public Temporal adjustInto(Temporal temporal) Parameters: This method accepts temporal as parameter which is the target temporal object to be adjusted. It should not be null. Return value: This method returns the adjusted object. Exception: This method throws following Exceptions: DateTimeException - if unable to make the adjustment.ArithmeticException - if unable to make the adjustment. Below programs illustrate the adjustInto() method: Program 1: Java // Java program to demonstrate // MonthDay.adjustInto() method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create a MonthDay object MonthDay mday = MonthDay.of(10, 31); // print instance System.out.println("MonthDay :" + mday); // create a temporal object LocalDate date = LocalDate.parse("2007-12-03"); // print instance System.out.println("LocalDate :" + date); // apply adjustInto method of monthday class LocalDate updatedlocal = (LocalDate)mday.adjustInto(date); // print instance System.out.println("LocalDate after" + " applying adjustInto method: " + updatedlocal); } } Output:MonthDay :--10-31 LocalDate :2007-12-03 LocalDate after applying adjustInto method: 2007-10-31 Program 2: Java // Java program to demonstrate // MonthDay.adjustInto() method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create a MonthDay object MonthDay mday = MonthDay.of(12, 22); // print instance System.out.println("MonthDay :" + mday); // create a temporal object LocalDate date = LocalDate.parse("2017-12-03"); // print instance System.out.println("LocalDate :" + date); // apply adjustInto method of monthday class LocalDate updatedlocal = (LocalDate)mday.adjustInto(date); // print instance System.out.println("LocalDate after" + " applying adjustInto method: " + updatedlocal); } } Output:MonthDay :--12-22 LocalDate :2017-12-03 LocalDate after applying adjustInto method: 2017-12-22 References: https://docs.oracle.com/javase/10/docs/api/java/time/MonthDay.html#adjustInto(java.time.temporal.Temporal) Example : Java import java.io.*; import java.time.LocalDate; import java.time.MonthDay; public class GFG { public static void main(String[] args) { MonthDay monthDay = MonthDay.of(6, 26); LocalDate localDate = LocalDate.of(2023, 4, 13); LocalDate newDate = monthDay.adjustInto(localDate).query(LocalDate::from); System.out.println("Original LocalDate: " + localDate); System.out.println("Adjusted LocalDate: " + newDate); } } output : Original LocalDate: 2023-04-13 Adjusted LocalDate: 2023-06-26 Comment More infoAdvertise with us Next Article MonthDay adjustInto() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java java-basics Java-Functions Java-time package Java-MonthDay +1 More Practice Tags : Java Similar Reads MonthDay atYear() method in Java with Examples The atYear() method of MonthDay class in Java combines this month-day with a year to create a LocalDate. Syntax: public LocalDate atYear(int year) Parameter: This method accepts a parameter year which specifies the year to use which is in range [MIN_YEAR, MAX_YEAR] Returns: The function returns the 1 min read OffsetTime adjustInto() method in Java with examples The adjustInto() method of OffsetDateTime class in Java adjusts the specified temporal object to have the same time as this object. Syntax : public Temporal adjustInto(Temporal temporal) Parameter : This method accepts a single parameter temporal which specifies the target object to be adjusted, not 2 min read OffsetDateTime adjustInto() method in Java with examples The adjustInto() method of OffsetDateTime class in Java adjusts the specified temporal object to have the same date and time as this object. Syntax : public Temporal adjustInto(Temporal temporal) Parameter : This method accepts a single parameter temporal which specifies the target object to be adju 2 min read Year adjustInto() Method in Java with Examples adjustInto() method of the Year class used to adjusts the passed temporal object to have this year on which this method is applied.This instance is immutable and unaffected by this method call. Syntax: public Temporal adjustInto(Temporal temporal) Parameters: This method accepts temporal as paramete 2 min read MonthDay with() Method in Java with Examples with(Month month) method of the MonthDay class used to alter the month-of-year of MonthDay object using month passed as a parameter and after that method returns the copy of altered MonthDay.If the day-of-month value is invalid for the specified month after altering operation, the day will be adjust 2 min read Like