문제

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