Try this (Remember Month value is 0, for example, 0 for January)
Calendar cal = Calendar.getInstance();
cal.set(year, month, 1);
cal.add(Calendar.MONTH, 1);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.DATE, -1);
cal.add(Calendar.DATE, -(cal.get(Calendar.DAY_OF_WEEK) -1));
return cal.getTime().toString().substring(0, 10);
So, if you want to call this method for Oct 2015, then call like this:
getLastSunday(9, 2015);
:
1. getLastSunday (9, 2015);
2. :
cal.add(Calendar.MONTH, 1);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.DATE, -1);
- :
JAVA 1 , 2 . , - , .. 2, 1 , .
, .