Joda Time, Get week days [duplicate]

£可爱£侵袭症+ 提交于 2019-12-04 05:09:47
Joe2013

Use the getDayOfWeek() method. Return will be as follows. Inorder to get only week days.. you just need to check whether the return value is less than or equal to 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;
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++;
        }

    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!