<span style="font-size:24px;">//model为字符串的时间格式,如"<span style="font-family: arial; line-height: 20.02px;">yy-MM-dd</span><span style="font-family: arial; line-height: 20.02px;"> HH:mm:ss"</span></span>
<span style="font-size:24px;">public class DateFormat {
public static Date StringToDate(String date,String model){ //字符串转时间
SimpleDateFormat simpleDateFormat=new SimpleDateFormat(model);
Date date1=null;
try {
date1=simpleDateFormat.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return date1;
}
public static String DateToString(Date date,String model){ //时间转字符串
SimpleDateFormat simpleDateFormat=new SimpleDateFormat(model);
return simpleDateFormat.format(date);
}
}</span>