Search code examples
androidalarmmanagerdayofweekweekday

Check day of week in Android


I want to check if the current day of the week is Sunday or not. How can I find it out? I am using this in alarm activity. Please help me. I want to setup an alarm which does not work on Sunday. Thanks in advance.


Solution

  • use the calendar class to check that information.

     Calendar rightNow = Calendar.getInstance();
     int day = rightNow.get(Calendar.DAY_OF_WEEK);
     if(day==Calendar.SUNDAY){
       //its sunday
     }