字符串轉日期:
public static Date strToDate(String str) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
日期轉字符串:
public static String getFisrtDayOfMonth(Date date){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String firstDayOfMonth = sdf.format(date.getTime());
return firstDayOfMonth;
}