how to get date of monday of current week instead of sunday below is my code which give me output with times i dont want times
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0); // ! clear would not reset the hour of day !
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);
// get start of this week in milliseconds
cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
Log.d(tag,"Start of this week : " + cal.getTime());
this give output likr this
Sun Sep 08 00:00:00 GMT+05:00 2013
and i wan to get like this
Mon Sep9 2013 only
Week's begining depends on location accroding to documentation. But in your case I suggest using cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
to get needed output
在日历周中,从星期日开始,因此获取第二天而不是第一天获取星期一。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.