1、日期转换成String格式化输出:
public String getDate() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String day = format.format(date);
return day;
}
2、String类型转化成日期
public void toDate(){
String sDate = "2015-08-21";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date dDate = sdf.parse(sDate); } catch (ParseException e) { e.printStackTrace();
}
}