I have the following code in a method:

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());

so what I want is to get a String of the format "EE, dd.MM.yyyy" of the next week. so it looks like that calendar.getTime() is returning the actual week...

有帮助吗?

解决方案

If you want the next week, use this code:

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

Note that new Calender() returns the current week. I do not know GregorianCalendar(). You may have a try.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top