在JodaTime,可以计算下周末的第一天吗?例如,现在是2014年5月19日(星期一),下周末的第一天是星期六24.05.2014。
答案 0 :(得分:0)
// algorithm valid for ISO-8601-definition of a week
// (every week starting on Monday)
LocalDate date = LocalDate.now(); // in system timezone
// move after current weekend
if (date.getDayOfWeek() >= 6) {
date = date.plusDays(2);
}
// move to next Saturday (your definition of first day of a weekend)
date = date.withDayOfWeek(6);
System.out.println(date); // 2014-05-24 (if today is 2014-05-19)