javaandroidcalendar

java check if date is first Sunday of the Month


I have been looking and searching a lot for this question. I'm really stupid when it comes to using the JAVA Calendar class.

Could anybody please help me to show a simple way of how to get the current time (on the android phone) and check whether is the first Sunday of the month or not.

// Comments in the code examples are very welcome :-)


Solution

  • Calendar cal = Calendar.getInstance();
    if (Calendar.SUNDAY == cal.get(Calendar.DAY_OF_WEEK) && cal.get(Calendar.DAY_OF_MONTH) <= 7)