//今日の日付を取得する
//例:今日(9/3(tue)→9/2(mon)を取得する)
//localDate使用不可のため、カレンダーを使用している
Date today = new Date();
Calendar day = Calendar.getInstance();
//月曜日を取得するメソッド
day.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
today = day.getTime();
//String型に整形する(必要に応じて)
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String strToday = sdf.format(today);
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme