Java LocalDateTime plusMonths() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Java 8+

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.

Java
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
CallWhat 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
// java.time.LocalDateTime
public LocalDateTime plusMonths(long months)

Parameters

ParameterDescription
months (long)The number of months to add. It can be zero or negative.

Return Value

Return ValueDescription
LocalDateTimeA new LocalDateTime with the months added. The original is not changed.

Compare with Similar Methods

Methods that move a date-time in time:

MethodHow 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

Example 1 — Find Subscription Renewal Dates

A subscription starts on 15 March. Print the renewal date after 1, 6, and 12 months.

Java
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));
    }
}

How It Works

  1. The start date. The subscription begins on 15 March 2026 at 08:00.
  2. One month later. The day number 15 stays the same and the month becomes April.
  3. Six months later. The date is 15 September 2026.
  4. 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.

Java
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));
    }
}

How It Works

  1. No 31 February. Adding a month to 31 January 2026 gives 28 February, the last day of that month.
  2. Leap years. In 2024 February has 29 days, so the answer is 29 February.
  3. April has 30 days. 31 March plus 1 month becomes 30 April.
  4. 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.

Java
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);
    }
}

How It Works

  1. The first step. 31 January plus 1 month is cut back to 28 February.
  2. The second step starts from the 28th. Java does not remember the original 31, so 28 February plus 1 month is 28 March.
  3. One jump keeps the 31. 31 January plus 2 months is 31 March, which exists.
  4. Lesson. When the day of the month matters, add all the months in one call from the original date.

Frequently Asked Questions

Call dt.plusMonths(n). It returns a new LocalDateTime, so store it: dt = dt.plusMonths(n).
No. LocalDateTime is immutable, so plusMonths() returns a new object and leaves the original as it was.
Yes. A negative number moves the other way, so dt.plusMonths(-n) gives the same result as dt.minusMonths(n).
28 February in a normal year and 29 February in a leap year. Java uses the last valid day of the new month.
Use dt.plusMonths(1). If next month is shorter and has no such day, you get its last day.

Next: plusNanos()

Return a copy that is a number of nanoseconds later.

plusNanos() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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