Use the get method of the Calendar class.
public static int getOccurenceOfDayInMonth() {
return Calendar.getInstance().get(Calendar.DAY_OF_WEEK_IN_MONTH);
}
[EDIT]
Here is a solution giving any date, not the current date.
public static int getOccurenceOfDayInMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH);
}
source
share