Close

Java Date Time - DayOfWeek.minus() Examples

Java Date Time Java Java API 


Class:

java.time.DayOfWeek

java.lang.Objectjava.lang.Objectjava.lang.Enumjava.lang.Enumjava.lang.ComparableComparablejava.io.SerializableSerializablejava.time.DayOfWeekjava.time.DayOfWeekjava.time.temporal.TemporalAccessorTemporalAccessorjava.time.temporal.TemporalAdjusterTemporalAdjusterLogicBig

Method:

public DayOfWeek minus(long days)

Returns the day-of-week subtracted by specified number of days

If the specified number is more than 7 then the calculation rolls around.

If the specified number is negative then days are added rather than being subtracted.


Examples:


package com.logicbig.example.dayofweek;

import java.time.DayOfWeek;

public class MinusExample {
public static void main (String[] args) {
DayOfWeek d = DayOfWeek.MONDAY.minus(4);
System.out.println(d);

d = DayOfWeek.MONDAY.minus(20);
System.out.println(d);

d = DayOfWeek.MONDAY.minus(-2);
System.out.println(d);
}
}

Output

THURSDAY
TUESDAY
WEDNESDAY




See Also