In Java Calendar exists method set. E.g. now is 01/11/2011. If we make like:
Calendar now = new GregorianCalendar();
now.set(GregorianCalendar.DAY_OF_WEEK,Calendar.FRIDAY);
Calendar will be set to nearest Friday, but for date more than now.
In docs written nothing if always go to the greater date.
Anybody can confirm that?
Thanks.
It always sets it to the given day-of-week within the same week. The first day of the week will depend on the calendar and locale.
For example, using the default calendar on my machine in the UK, Monday is the first day of the week – so setting the day of week to Monday today results in October 31st, whereas setting the day of week to Sunday results in November 6th. However, if I use:
… then the first day of the week is Sunday, and the result is October 30th.
You can set the first day of the week explicitly using
setFirstDayOfWeek.