`
l540151663
  • 浏览: 182381 次
  • 性别: Icon_minigender_1
  • 来自: 浙江
社区版块
存档分类
最新评论

时间字符串转化Date

    博客分类:
  • java
 
阅读更多

//从时间字符串转化为date类型
public static Date strToDate(String src, String format)
{
//format =  "yyyyMMddHHmm" 等等类型

if (src.length() != format.length())
return null;

SimpleDateFormat dateFormat = new SimpleDateFormat(format);
dateFormat.setLenient(false);

try
{
Date date = dateFormat.parse(src);
return date;
}
catch(Exception e)
{
return null;
}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics