我需要每週的姓名,但依賴於實際的日期和日期。例如,我需要今天的名字,然後明天的名字,日期的名稱+2天等我做這個代碼,但不工作良好。那麼有沒有更好的辦法讓我可以在android中獲得一天的名字?字符串格式的日期名稱,需要幾天的時間
public String getDay3Name() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
String[] days = new String[] { "SUNDAY","SUNDAY","SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY" };
String day = days[calendar.get(Calendar.DAY_OF_WEEK)+1];
return day;
}
public String getDay4Name() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
String[] days = new String[] { "SUNDAY","SUNDAY","SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY" };
String day = days[calendar.get(Calendar.DAY_OF_WEEK)+2];
return day;
}
thx很棒。) –