08-06
20
format String to Date
作者:Java伴侣 日期:2008-06-20
jdk中已经不再推荐用Date.parse(String arg);这样的直接的转换,取而代之的是:
复制内容到剪贴板 程序代码
String birthdayS = request.getParameter("birthday");
DateFormat f=new SimpleDateFormat("yyyy-MM-dd");
try {
birthday=f.parse(birthdayS);
} catch (ParseException e) {
e.printStackTrace();
log.error("When format birthday from String to Date is error");
}
user.setBirthday(birthday);
DateFormat f=new SimpleDateFormat("yyyy-MM-dd");
try {
birthday=f.parse(birthdayS);
} catch (ParseException e) {
e.printStackTrace();
log.error("When format birthday from String to Date is error");
}
user.setBirthday(birthday);
评论: 0 | 引用: 0 | 查看次数: 626
发表评论