前幾寫了時間轉化星期幾的方式,做個記錄,廢話不說,直接上代碼;
public static String strToDate(String strDate) throws ParseException {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(formatter.parse(strDate));
SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
String week = sdf.format(c.getTime());
return week;
}
上面的方法直接傳個時間就能轉化,返回就是星期