How to check the day in Android?

Possible duplicate:
What is the easiest way to get the current day of the week in Android?

I want to make an application with the question: "Is it Friday?" And by what you will see β€œNo” or β€œYes” if on Friday. So my question is: How can I check if it is Friday today? I hope you understand me, otherwise just ask me.

Gauwe

0
source share
3 answers

You should use the java.util.Calendar class.

Indication of documentation:

Calendar rightNow = Calendar.getInstance(); if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY){ //do some stuff here } 
+3
source

see this: http://developer.android.com/reference/java/util/Date.html u probably want to create an instance of the calendar and set it to the current date and get the day of the week (Calendar.DAY_OF_WEEK) and compare with Friday (friday = 6, if I remember correctly ?, check this pls) or use the new date () ....

0
source

This is simple:

  private boolean isTodayFriday(){ Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY; } 
0
source

Source: https://habr.com/ru/post/922432/


All Articles