乔达时间(Joda Time),获取工作日 [英] Joda Time, Get week days

查看:78
本文介绍了乔达时间(Joda Time),获取工作日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使本地日期仅计算星期几?

How to make the local date count only week date?

例如

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 am look for a way to remove the weekends?

推荐答案

使用getDayOfWeek()方法.回报如下.为了只获得工作日,您只需要检查返回值是否小于或等于5.

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;

这篇关于乔达时间(Joda Time),获取工作日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆