2

我在方法中有以下代码:

final String WEEK_OF_YEAR    = "w";

GregorianCalendar calendar = new GregorianCalendar();
calendar.set(Calendar.WEEK_OF_YEAR, Integer.valueOf(get(WEEK_OF_YEAR)) + 1); 
//The get(WEEK_OF_YEAR) returns the actual week of the year

DateFormat formatter = new SimpleDateFormat("EE, dd.MM.yyyy");
return formatter.format(calendar.getTime());

所以我想要的是获得下周String的格式。"EE, dd.MM.yyyy"所以看起来这calendar.getTime()正在返回实际的一周......

4

1 回答 1

2

如果您想要下周,请使用以下代码:

 GregorianCalendar calendar = new GregorianCalendar();
 calendar.add(Calendar.WEEK_OF_YEAR, 1);

请注意, new Calender() 返回当前周。我不知道 GregorianCalendar()。你可以试一试。

于 2013-07-26T22:44:42.257 回答