Вопрос

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