How To Check 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 app with the question: 'Is it al Friday?' And than you would see 'No
Solution 1:
You should use the java.util.Calendar class.
Quoting the documentation :
Calendar rightNow = Calendar.getInstance();
if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY){
//do some stuff here
}
Solution 2:
see this: http://developer.android.com/reference/java/util/Date.html u probably want to create a calendar instance & set it to the current date and get the day of the week(Calendar.DAY_OF_WEEK) & compare with friday(friday = 6 if i remember correctly?,check on this pls) or use new date()....
Solution 3:
Simply this:
private boolean isTodayFriday(){
Calendar calendar = Calendar.getInstance();
return calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY;
}
Post a Comment for "How To Check Day In Android?"