Androidで取得した指定日は曜日です
private int getDayofWeek(String dateTime) {
Calendar cal = Calendar.getInstance();
if (dateTime.equals("")) {
cal.setTime(new Date(System.currentTimeMillis()));
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
Date date;
try {
date = sdf.parse(dateTime);
} catch (ParseException e) {
date = null;
e.printStackTrace();
}
if (date != null) {
cal.setTime(new Date(date.getTime()));
}
}
return cal.get(Calendar.DAY_OF_WEEK);
}
戻り値の説明:
1-日曜日
2-月曜日
3-火曜日
4-水曜日
5-木曜日
6-金曜日
7-土曜日
呼び出しeg:
getDayofWeek("2018-06-07");
戻り値によって曜日が表示され、複数の言語に対応して簡単で便利です