Java LocalDateTime minus() Method

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

Definition

In Java, minus(...) returns a new LocalDateTime that is earlier than the original. There are two versions. One takes a number and a TemporalUnit, such as minus(2, ChronoUnit.HOURS). The other takes a TemporalAmount, which is a Duration or a Period.

The methods minusDays(), minusHours() and the others are shortcuts. minus() reaches every unit, including weeks, centuries, and half-days.

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. It comes from Temporal, which LocalDateTime implements.

Syntax

Pass a number and a unit, or pass a Duration or Period.

Java
LocalDateTime dt = LocalDateTime.of(2026, 3, 15, 10, 30);
LocalDateTime a = dt.minus(1, ChronoUnit.WEEKS);          // 2026-03-08T10:30
LocalDateTime b = dt.minus(Duration.ofMinutes(90));       // 2026-03-15T09:00
LocalDateTime c = dt.minus(Period.ofMonths(3));           // 2025-12-15T10:30
CallWhat it does
dt.minus(n, unit)Subtracts n of a ChronoUnit, such as WEEKS or HOURS.
dt.minus(duration)Subtracts a Duration, which is an amount of time in seconds.
dt.minus(period)Subtracts a Period, which is an amount in years, months, and days.
dt.minusDays(n)The shortcut for minus(n, ChronoUnit.DAYS).

The original is never changed. minus() returns a new LocalDateTime.

Library declarations
Java
// java.time.LocalDateTime
public LocalDateTime minus(long amountToSubtract, TemporalUnit unit)
public LocalDateTime minus(TemporalAmount amountToSubtract)

Parameters

ParameterDescription
amountToSubtract (long)The number of units to subtract. It can be negative.
unit (TemporalUnit)The unit, such as ChronoUnit.MINUTES.
amountToSubtract (TemporalAmount)A Duration or a Period. Use this version without the unit.

Return Value

Return ValueDescription
LocalDateTimeA new LocalDateTime with the amount subtracted.

Compare with Similar Methods

Ways to move a date-time:

MethodHow it differs
plus(n, unit)The opposite direction.
minusDays(n)A shortcut for one unit.
until(end, unit)Measures the distance instead of moving.

Java Examples

Example 1 — Subtract in Different Units

Subtract a week, two hours, a century, and half a day from the same date-time.

Java
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class LdtMinusUnits {
    public static void main(String[] args) {
        LocalDateTime dt = LocalDateTime.of(2026, 3, 15, 10, 30);

        System.out.println("-1 week:     " + dt.minus(1, ChronoUnit.WEEKS));
        System.out.println("-2 hours:    " + dt.minus(2, ChronoUnit.HOURS));
        System.out.println("-1 century:  " + dt.minus(1, ChronoUnit.CENTURIES));
        System.out.println("-1 half day: " + dt.minus(1, ChronoUnit.HALF_DAYS));
    }
}

How It Works

  1. Every unit in one method. The second argument says what the number counts.
  2. A week and two hours. The results are 8 March at 10:30 and 15 March at 08:30.
  3. A century. One hundred years earlier is 15 March 1926.
  4. Half a day. HALF_DAYS is 12 hours, so 10:30 becomes 22:30 on the day before.

Example 2 — Subtract a Duration and a Period

Subtract 90 minutes as a Duration, three months as a Period, and a mixed Period of years, months, and days.

Java
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.Period;

public class LdtMinusAmounts {
    public static void main(String[] args) {
        LocalDateTime dt = LocalDateTime.of(2026, 3, 15, 10, 30);

        System.out.println("90 minutes:  " + dt.minus(Duration.ofMinutes(90)));
        System.out.println("3 months:    " + dt.minus(Period.ofMonths(3)));
        System.out.println("1y 2m 3d:    " + dt.minus(Period.of(1, 2, 3)));
    }
}

How It Works

  1. A Duration is exact time. 90 minutes before 10:30 is 09:00.
  2. A Period is calendar time. Three months before March is December of the previous year.
  3. A mixed Period. Going back 1 year and 2 months gives 15 January 2025, and the 3 extra days make it 12 January 2025.

Example 3 — Undo a Difference with minus

Measure the Duration between two date-times, then subtract it from the later one to get the earlier one back.

Java
import java.time.Duration;
import java.time.LocalDateTime;

public class LdtMinusUndo {
    public static void main(String[] args) {
        LocalDateTime start = LocalDateTime.of(2026, 3, 15, 8, 0);
        LocalDateTime end = LocalDateTime.of(2026, 3, 16, 10, 30);

        Duration gap = Duration.between(start, end);
        System.out.println("gap:      " + gap);
        System.out.println("end - gap: " + end.minus(gap));
        System.out.println("equals start: " + end.minus(gap).equals(start));
    }
}

How It Works

  1. Two date-times. They are 26 and a half hours apart.
  2. A Duration holds the gap. Duration.between prints in the ISO form PT26H30M, which means 26 hours and 30 minutes.
  3. Subtract it again. end.minus(gap) goes back by exactly that gap.
  4. Back at the start. The result equals start, so the last line prints true.

Frequently Asked Questions

Use dt.minus(Duration.ofMinutes(90)). A Duration is an exact length of time.
Use dt.minus(Period.ofMonths(3)) or Period.of(years, months, days). It follows calendar rules.
There is no difference. minusDays(n) is a shortcut for the same call.
All of them except FOREVER, from NANOS up to ERAS. For example WEEKS, DECADES, CENTURIES, and HALF_DAYS.
Use plus(n, unit), or pass a negative number such as minus(-1, ChronoUnit.DAYS).

Next: minusDays()

Return a copy that is a number of days earlier.

minusDays() 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