我想要获取某周特定日期的日期,以周数标识。如何获得特定一周中特定日期的日期
下面是一个例子:
今天是星期一(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日,而不管周数是多少?你是否也在意在本周的第一天不是星期一? –