Time in Jod, Get the Days of the Week

How to calculate the local date only a week?

for instance

LocalDate date = new LocalDate();
date.plusDays(10); //it returns plus days including sat and sun as 2013-03-21
//i am looking for a way
date.plusDays(10); //should return as 2013-03-26

I'm looking for a way to delete a weekend?

+5
source share
2 answers

Use the method getDayOfWeek(). Refund will be as follows. To get only weekly days .. you just need to check if less or less than 5.

public static final int MONDAY = 1;
public static final int TUESDAY = 2;
public static final int WEDNESDAY = 3;
public static final int THURSDAY = 4;
public static final int FRIDAY = 5;
public static final int SATURDAY = 6;
public static final int SUNDAY = 7;
+17
source
LocalDate newDate = new LocalDate();
    int i=0;
    while(i<days)//days == as many as u wanted
    {
        newDate = newDate.plusDays(1);
        System.out.println("new date"+newDate);
        if(newDate.getDayOfWeek()<=5)
        {
            i++;
        }

    }
+5
source

All Articles