我想要獲取某周特定日期的日期,以週數標識。如何獲得特定一週中特定日期的日期
下面是一個例子:
今天是星期一(2016年10月3日),它是在本週58 現在我想要得到的例如日期數本週五。
我在我的android應用程序中使用Joda-Time。
目前Iam正在創建LocalDate。
// This is the date of today
private LocalDate reportDate = new LocalDate();
// The number of the week is calculated here
int week = Weeks.weeksBetween(startDate.dayOfWeek().withMinimumValue().minusDays(1),
reportDate.dayOfWeek().withMaximumValue().plusDays(1)).getWeeks();
switch(day_of_week) {
case "Monday":
// Get date of this day in current week
break;
case "Tuesday":
// Get date of this day in current week
break;
// ...
我不清楚週數是如何影響計算的。如果報告日期是10月3日,而星期幾是星期二,則大概答案將是10月4日,而不管週數是多少?你是否也在意在本週的第一天不是星期一? –