Question

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...

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top