如何将string类型的日期转化成日期
展开全部
String转换为Date
[java] view
plaincopyprint?
//String转换为java.util.Date
String str = "2013-01-14";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = null; //初始化date
try {
date = sdf.parse(str); //Mon Jan 14 00:00:00 CST 2013
} catch (ParseException e) {
e.printStackTrace();
}
//String转换为java.util.Date
String str = "2013-01-14";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = null; //初始化date
try {
date = sdf.parse(str); //Mon Jan 14 00:00:00 CST 2013
} catch (ParseException e) {
e.printStackTrace();
}
[java] view
plaincopyprint?
//String转换为java.util.Date
String str = "2013-01-14";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = null; //初始化date
try {
date = sdf.parse(str); //Mon Jan 14 00:00:00 CST 2013
} catch (ParseException e) {
e.printStackTrace();
}
//String转换为java.util.Date
String str = "2013-01-14";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = null; //初始化date
try {
date = sdf.parse(str); //Mon Jan 14 00:00:00 CST 2013
} catch (ParseException e) {
e.printStackTrace();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询