[java]代码库
//从 yyyyMMdd 返回 星期几
public static String getDayAndWeek(String day){
if(day.length()<8){
return day;
}
Calendar c = new GregorianCalendar();
DateFormatSymbols dfs = new DateFormatSymbols();
String[] weeks = dfs.getWeekdays();
int year = Integer.parseInt(day.substring(0,4));
int month =Integer.parseInt( day.substring(4,6));
int day_ = Integer.parseInt( day.substring(6,8));
c.set(year, month-1, day_); //Calendar的月从0-11,所以4月是3.
c.get(Calendar.DAY_OF_WEEK);
String week = weeks[c.get(Calendar.DAY_OF_WEEK)];
week = "星期"+week.substring(2);
day = day_+ "("+week+")";
return day;
}
//源代码片段来自云代码http://yuncode.net