/**
* 字符串日期转为时间
*/
private Date StringDateToDate(String dateStr)
{
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date date = null;
try
{
date = formatDate.parse(dateStr);
} catch (ParseException e)
{
e.printStackTrace();
}
return date;
}
* 字符串日期转为时间
*/
private Date StringDateToDate(String dateStr)
{
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date date = null;
try
{
date = formatDate.parse(dateStr);
} catch (ParseException e)
{
e.printStackTrace();
}
return date;
}
本文介绍了一个使用Java的SimpleDateFormat类将字符串日期转换为时间的简单方法。通过实例演示了如何解析指定格式的日期字符串,并将其转换为Date对象。
742

被折叠的 条评论
为什么被折叠?



