public class DateUtil {
/**
* 获取月、日和星期
*
* @return
*/
public static String getMonthAndDay() {
String currentDay;
Calendar calendar = Calendar.getInstance();
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
int getDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
if (getDayOfWeek == Calendar.SUNDAY) {
currentDay = "星期日";
} else if (getDayOfWeek == Calendar.MONDAY) {
currentDay = "星期一";
} else if (getDayOfWeek == Calendar.TUESDAY) {
currentDay = "星期二";
} else if (getDayOfWeek == Calendar.WEDNESDAY) {
currentDay = "星期三";
} else if (getDayOfWeek == Calendar.THURSDAY) {
currentDay = "星期四";
} else if (getDayOfWeek == Calendar.FRIDAY) {
currentDay = "星期五";
} else if (getDayOfWeek == Calendar.SATURDAY) {
currentDay = "星期六";
} else {
currentDay = "";
}
return month + "月" + day + "日 " + currentDay;
}
}
Android:获取当前时间是几月几日星期几
于 2024-11-19 10:03:26 首次发布