Learn from:http://my.oschina.net/hermer/blog/151274
/*** Test *@paramargs*/ Public Static voidMain (string[] args) {//define the output date formatSimpleDateFormat SDF =NewSimpleDateFormat ("Yyyy-mm-dd EEE"); Date currentdate=NewDate (); //like today's 2012-12-25 .List<date> days =Datetoweek (currentdate); System.out.println ("Today's Date:" +Sdf.format (currentdate)); for(date date:days) {System.out.println (Sdf.format (date)); } } /*** Date of the week based on date *@paramMdate *@return */@SuppressWarnings ("Deprecation") Public StaticList<date>Datetoweek (Date mdate) {intb =Mdate.getday (); Date fdate; List<Date> list =NewArraylist<date>(); Long Ftime= Mdate.gettime ()-B * 24 * 3600000; for(intA = 1; a <= 7; a++) {fdate=NewDate (); Fdate.settime (Ftime+ (A * 24 * 3600000)); List.add (A-1, fdate); } returnlist; }
Java--Get all the dates of the current week based on the current date