Home Java LocalDateTime Methods minusWeeks() Java LocalDateTime minusWeeks() Method 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.
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 Call What 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.time.LocalDateTime
public LocalDateTime minusWeeks(long weeks) Parameters Parameter Description weeks (long)The number of weeks to subtract. It can be zero or negative.
Return Value Return Value Description LocalDateTimeA new LocalDateTime with the weeks subtracted. The original is not changed.
Compare with Similar Methods Methods that move a date-time in time:
Method How 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 1. Event reminders 2. Across New Year 3. Weeks vs days Example 1 — Schedule Reminders Before an Event An event is on Friday at 18:30. Send a reminder one week and two weeks before.
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));
}
} event: 2026-04-10T18:30
1 week: 2026-04-03T18:30
2 weeks: 2026-03-27T18:30 How It Works The event. Friday 10 April 2026 at 18:30.One week before. minusWeeks(1) is Friday 3 April at 18:30.Two weeks before. minusWeeks(2) is 27 March, so the month goes back to March.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.
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));
}
} 2 weeks back: 2026-12-28T09:00
3 weeks back: 2026-12-21T09:00 How It Works Start in January. 11 January 2027 at 09:00 is a Monday.Two weeks back. That is 14 days, which lands on 28 December 2026, so the year goes back by one.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.
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)));
}
} by weeks: 2026-02-15T10:30
by days: 2026-02-15T10:30
all equal: true How It Works Four weeks back. minusWeeks(4) goes from 15 March to 15 February.28 days gives the same date. Four weeks and 28 days are the same amount of time.A negative plus also agrees. plusWeeks(-4) goes backwards too.equals checks all three. The last line prints true.Frequently Asked Questions How do I subtract weeks from a LocalDateTime in Java? Call dt.minusWeeks(n). It returns a new LocalDateTime, so store it: dt = dt.minusWeeks(n).
Does minusWeeks() change the original LocalDateTime? No. LocalDateTime is immutable, so minusWeeks() returns a new object and leaves the original as it was.
Can I pass a negative number to minusWeeks()? Yes. A negative number moves the other way, so dt.minusWeeks(-n) gives the same result as dt.plusWeeks(n).
How do I get the date one week ago in Java? Call dt.minusWeeks(1), or LocalDateTime.now().minusWeeks(1) for one week before now.
Is minusWeeks(n) the same as plusWeeks(-n)? Yes. Both move the date back by n times 7 days.
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.
10 people found this page helpful
Helpful Share Copy link Suggestion