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 开发者_如何学Python"No" or "Yes" if it's Friday. So my question is: How can i check if today it's friday? I hope you understand me, otherwise just ask me.
Gaauwe
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
}
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()....
Simply this:
private boolean isTodayFriday(){
Calendar calendar = Calendar.getInstance();
return calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY;
}
精彩评论