据我所知,在Joda Time中没有为你自动执行此操作的内置方法.但是,您可以编写自己的方法,在循环中递增日期,直到达到工作日.
请注意,根据您的需要,这可能会比您想象的要复杂得多.例如,它是否应该跳过假期?哪些日子是假期取决于你所在的国家.此外,在一些国家(例如,阿拉伯国家),周末是周四和周五,而不是周六和周日.
LocalDate newDate = new LocalDate();
int i=0;
while(i<days)//days == as many days as u want too
{
newDate = newDate.plusDays(1);//here even sat and sun are added
//but at the end it goes to the correct week day.
//because i is only increased if it is week day
if(newDate.getDayOfWeek()<=5)
{
i++;
}
}
System.out.println("new date"+newDate);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9840 次 |
| 最近记录: |