Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get dates of a week (I know week number)?

Tags:

I know the week number of the year, a week is start from Sunday, then Monday, Tuesday...,Saturday.

Since I know the week number, what's the efficient way to get the dates of the specific week by using Java code??

like image 237
Mellon Avatar asked Oct 15 '10 11:10

Mellon


1 Answers

If you don't want external library, just use calendar.

SimpleDateFormat sdf = new SimpleDateFormat("MM dd yyyy"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.WEEK_OF_YEAR, 23);         cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); System.out.println(sdf.format(cal.getTime()));     
like image 65
bungrudi Avatar answered Oct 05 '22 18:10

bungrudi