joda时间 - 添加工作日到目前为止 [英] joda time - add weekdays to date

查看:147
本文介绍了joda时间 - 添加工作日到目前为止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将工作日添加到joda时间?

Is it possible to add weekdays to joda time?

例如,如果当前日期是01/03周五,则日期+ 1应该返回04/03周一,而不是02/03。

For instance, if current date is Friday 01/03, date + 1 should return Monday 04/03, rather than 02/03.

推荐答案

据我所知,在Joda Time中没有为你自动执行此操作的内置方法。但是,您可以编写自己的方法,在循环中递增日期,直到达到工作日。

As far as I know there is no built-in method to automatically do this for you in Joda Time. However, you could write your own method, that increments the date in a loop until you get to a weekday.

请注意,完全取决于您的需要,这可能比你想象的要复杂得多。例如,它也应该跳过假期吗?哪些日子是假期取决于你所在的国家。此外,在一些国家(例如,阿拉伯国家),周末是周四和周五,而不是周六和周日。

Note that, depending on what you need it for exactly, this could be (much) more complicated than you think. For example, should it skip holidays too? Which days are holidays depends on which country you're in. Also, in some countries (for example, Arabic countries) the weekend is on Thursday and Friday, not Saturday and Sunday.

这篇关于joda时间 - 添加工作日到目前为止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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