Home Java LocalDateTime Methods plusMonths() Java LocalDateTime plusMonths() Method Definition In Java, plusMonths(months) returns a new LocalDateTime that is the given number of months later than the original. The year changes by itself when the months pass December, and the time of day stays the same.
LocalDateTime is immutable , so the original object never changes. Always keep the result: dt = dt.plusMonths(1);. Months have different lengths, so this method has one special rule, explained under "Important" below.
An instance method of java.time.LocalDateTime (since Java 8): call it on a LocalDateTime object. Add import java.time.LocalDateTime; at the top of your file.
Syntax Call it on a LocalDateTime and pass the number of months. A negative number goes the other way.
LocalDateTime start = LocalDateTime.of(2026, 3, 15, 8, 0);
LocalDateTime result = start.plusMonths(1); // 2026-04-15T08:00
System.out.println(start); // 2026-03-15T08:00 Call What it does dt.plusMonths(n)Returns a new date-time with n months added. dt.minusMonths(n)The same idea in the opposite direction. dt.plus(n, ChronoUnit.MONTHS)The general form. It does the same thing for this unit. date.plusMonths(n)LocalDate has the same method, with the same end-of-month rule.
The result is a new object . Calling plusMonths() without using the returned value does nothing useful.
Library declarations // java.time.LocalDateTime
public LocalDateTime plusMonths(long months) Parameters Parameter Description months (long)The number of months to add. It can be zero or negative.
Return Value Return Value Description LocalDateTimeA new LocalDateTime with the months added. The original is not changed.
Important
If the day does not exist in the new month, Java uses the last valid day of that month instead of failing: 31 January plus 1 month is 28 February (or 29 February in a leap year). The change is not remembered, so adding 1 month twice can give a different answer from adding 2 months once.
Compare with Similar Methods Methods that move a date-time in time:
Method How it differs minusMonths(n)The opposite direction for months. plus(n, unit)The general method: you choose the unit as an argument. plusYears(n)Adds whole years, which keeps the month and day. plusDays(n)Adds exact days, with no end-of-month rule.
Java Examples 1. Renewal dates 2. End of month 3. Step by step Example 1 — Find Subscription Renewal Dates A subscription starts on 15 March. Print the renewal date after 1, 6, and 12 months.
import java.time.LocalDateTime;
public class LdtPlusMonthsDemo {
public static void main(String[] args) {
LocalDateTime start = LocalDateTime.of(2026, 3, 15, 8, 0);
System.out.println("1 month: " + start.plusMonths(1));
System.out.println("6 months: " + start.plusMonths(6));
System.out.println("12 months: " + start.plusMonths(12));
}
} 1 month: 2026-04-15T08:00
6 months: 2026-09-15T08:00
12 months: 2027-03-15T08:00 How It Works The start date. The subscription begins on 15 March 2026 at 08:00.One month later. The day number 15 stays the same and the month becomes April.Six months later. The date is 15 September 2026.Twelve months later. The year moves on to 2027 and the month is March again.Example 2 — See the End-of-Month Rule Add one month to the 31st of a month, in a normal year, in a leap year, and into a 30-day month.
import java.time.LocalDateTime;
public class LdtPlusMonthsEnd {
public static void main(String[] args) {
LocalDateTime jan2026 = LocalDateTime.of(2026, 1, 31, 9, 0);
LocalDateTime jan2024 = LocalDateTime.of(2024, 1, 31, 9, 0);
LocalDateTime mar2026 = LocalDateTime.of(2026, 3, 31, 9, 0);
System.out.println("31 Jan 2026 + 1 month: " + jan2026.plusMonths(1));
System.out.println("31 Jan 2024 + 1 month: " + jan2024.plusMonths(1));
System.out.println("31 Mar 2026 + 1 month: " + mar2026.plusMonths(1));
}
} 31 Jan 2026 + 1 month: 2026-02-28T09:00
31 Jan 2024 + 1 month: 2024-02-29T09:00
31 Mar 2026 + 1 month: 2026-04-30T09:00 How It Works No 31 February. Adding a month to 31 January 2026 gives 28 February, the last day of that month.Leap years. In 2024 February has 29 days, so the answer is 29 February.April has 30 days. 31 March plus 1 month becomes 30 April.No exception. Java quietly picks the last valid day, so the code keeps running.Example 3 — One Big Jump or Two Small Steps Start at 31 January. Add one month twice, and then add two months in one call.
import java.time.LocalDateTime;
public class LdtPlusMonthsSteps {
public static void main(String[] args) {
LocalDateTime jan31 = LocalDateTime.of(2026, 1, 31, 9, 0);
LocalDateTime twoSteps = jan31.plusMonths(1).plusMonths(1);
LocalDateTime oneJump = jan31.plusMonths(2);
System.out.println("after one month: " + jan31.plusMonths(1));
System.out.println("two steps: " + twoSteps);
System.out.println("one jump: " + oneJump);
}
} after one month: 2026-02-28T09:00
two steps: 2026-03-28T09:00
one jump: 2026-03-31T09:00 How It Works The first step. 31 January plus 1 month is cut back to 28 February.The second step starts from the 28th. Java does not remember the original 31, so 28 February plus 1 month is 28 March.One jump keeps the 31. 31 January plus 2 months is 31 March, which exists.Lesson. When the day of the month matters, add all the months in one call from the original date.Frequently Asked Questions How do I add months to a LocalDateTime in Java? Call dt.plusMonths(n). It returns a new LocalDateTime, so store it: dt = dt.plusMonths(n).
Does plusMonths() change the original LocalDateTime? No. LocalDateTime is immutable, so plusMonths() returns a new object and leaves the original as it was.
Can I pass a negative number to plusMonths()? Yes. A negative number moves the other way, so dt.plusMonths(-n) gives the same result as dt.minusMonths(n).
What is 31 January plus one month in Java? 28 February in a normal year and 29 February in a leap year. Java uses the last valid day of the new month.
How do I get the same date next month in Java? Use dt.plusMonths(1). If next month is shorter and has no such day, you get its last day.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
12 people found this page helpful
Helpful Share Copy link Suggestion