我有周數和年份,我想要得到星期的第一天和最後一天的日期,這是我的代碼,它給出我錯了結果,請告訴我我做錯了什麼。提前致謝。給周編號和年份找到星期的第一天和最後一天
SimpleDateFormat dt = new SimpleDateFormat("dd/mm/yyyy");
String start ="";
String end ="";
int week = 38;
int yeat = 2016;
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.WEEK_OF_YEAR, week);
calendar.set(Calendar.YEAR, year);
// firt day of week
start = dt.format(calendar.getTime());
calendar.add(Calendar.DAY_OF_MONTH, 6);
//last day of week
end = dt.format(calendar.getTime());
可能重複:如何計算在Java的ISO8601星期數日期(http://stackoverflow.com/q/25084576/642706) –