simpleDateFormat时间转换所有技巧

1.基本的见博客    https://blog.csdn.net/hanchaob323/article/details/7371731

2. 自己转换 

//解析时间 有时候不能直接把String转为string类型。只能通过一个中间Date类型来转换
private String dateToString(String dateStr){
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date applyDate = null;

String strDate = null;
try {
applyDate = formatter.parse(dateStr);
strDate = format.format(applyDate);
} catch (ParseException e) {
e.printStackTrace();
}
return strDate;
}
posted @ 2018-05-03 13:51  塑料味的美年达  阅读(357)  评论(0编辑  收藏  举报