Java LocalDateTime minusWeeks() Method

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

Definition

In Java, minusWeeks(weeks) returns a new LocalDateTime that is the given number of weeks earlier than the original. Each week is exactly 7 days, and the time of day stays the same.

LocalDateTime is immutable, so the original object never changes. Always keep the result: dt = dt.minusWeeks(1);. It is handy for "one week before" and "two weeks before" reminders.

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 weeks. A negative number goes the other way.

Java
LocalDateTime start = LocalDateTime.of(2026, 4, 6, 10, 0);
LocalDateTime result = start.minusWeeks(2);   // 2026-03-23T10:00
System.out.println(start);   // 2026-04-06T10:00
CallWhat it does
dt.minusWeeks(n)Returns a new date-time with n weeks subtracted.
dt.plusWeeks(n)The same idea in the opposite direction.
dt.minus(n, ChronoUnit.WEEKS)The general form. It does the same thing for this unit.
date.minusWeeks(n)LocalDate has the same method, but it has no time of day.

The result is a new object. Calling minusWeeks() without using the returned value does nothing useful.

Library declarations
Java
// java.time.LocalDateTime
public LocalDateTime minusWeeks(long weeks)

Parameters

ParameterDescription
weeks (long)The number of weeks to subtract. It can be zero or negative.

Return Value

Return ValueDescription
LocalDateTimeA new LocalDateTime with the weeks subtracted. The original is not changed.

Compare with Similar Methods

Methods that move a date-time in time:

MethodHow it differs
plusWeeks(n)The opposite direction for weeks.
minus(n, unit)The general method: you choose the unit as an argument.
minusDays(n)Subtracts single days. minusWeeks(1) equals minusDays(7).
minusMonths(n)Subtracts calendar months, which are not all the same length.

Java Examples

Example 1 — Schedule Reminders Before an Event

An event is on Friday at 18:30. Send a reminder one week and two weeks before.

Java
import java.time.LocalDateTime;

public class LdtMinusWeeksDemo {
    public static void main(String[] args) {
        LocalDateTime event = LocalDateTime.of(2026, 4, 10, 18, 30);

        System.out.println("event:      " + event);
        System.out.println("1 week:     " + event.minusWeeks(1));
        System.out.println("2 weeks:    " + event.minusWeeks(2));
    }
}

How It Works

  1. The event. Friday 10 April 2026 at 18:30.
  2. One week before. minusWeeks(1) is Friday 3 April at 18:30.
  3. Two weeks before. minusWeeks(2) is 27 March, so the month goes back to March.
  4. Always a Friday. Subtracting whole weeks never changes the weekday or the time.

Example 2 — Subtract Weeks Across the New Year

Start on 11 January 2027 and go back two and three weeks.

Java
import java.time.LocalDateTime;

public class LdtMinusWeeksNewYear {
    public static void main(String[] args) {
        LocalDateTime january = LocalDateTime.of(2027, 1, 11, 9, 0);

        System.out.println("2 weeks back: " + january.minusWeeks(2));
        System.out.println("3 weeks back: " + january.minusWeeks(3));
    }
}

How It Works

  1. Start in January. 11 January 2027 at 09:00 is a Monday.
  2. Two weeks back. That is 14 days, which lands on 28 December 2026, so the year goes back by one.
  3. Three weeks back. That is 21 days, and the date becomes 21 December 2026.

Example 3 — Compare minusWeeks with Other Ways

Subtract 4 weeks, subtract 28 days, and add -4 weeks. All three should agree.

Java
import java.time.LocalDateTime;

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

        LocalDateTime byWeeks = start.minusWeeks(4);
        LocalDateTime byDays = start.minusDays(28);
        LocalDateTime byNegative = start.plusWeeks(-4);

        System.out.println("by weeks:    " + byWeeks);
        System.out.println("by days:     " + byDays);
        System.out.println("all equal:   " + (byWeeks.equals(byDays) && byDays.equals(byNegative)));
    }
}

How It Works

  1. Four weeks back. minusWeeks(4) goes from 15 March to 15 February.
  2. 28 days gives the same date. Four weeks and 28 days are the same amount of time.
  3. A negative plus also agrees. plusWeeks(-4) goes backwards too.
  4. equals checks all three. The last line prints true.

Frequently Asked Questions

Call dt.minusWeeks(n). It returns a new LocalDateTime, so store it: dt = dt.minusWeeks(n).
No. LocalDateTime is immutable, so minusWeeks() returns a new object and leaves the original as it was.
Yes. A negative number moves the other way, so dt.minusWeeks(-n) gives the same result as dt.plusWeeks(n).
Call dt.minusWeeks(1), or LocalDateTime.now().minusWeeks(1) for one week before now.
Yes. Both move the date back by n times 7 days.

Next: minusYears()

Return a copy that is a number of years earlier.

minusYears() 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.

10 people found this page helpful