Close

Java Date Time - DayOfWeek.plus() 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 plus(long days)

Returns the day-of-week added 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 subtracted rather than being added.


Examples:


package com.logicbig.example.dayofweek;

import java.time.DayOfWeek;

public class PlusExample {

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

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

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

Output

FRIDAY
SUNDAY
SATURDAY




See Also