`
guoce
  • 浏览: 21917 次
  • 性别: Icon_minigender_2
  • 来自: 郑州
文章分类
社区版块
存档分类
最新评论

date类型转string类型

阅读更多
public class a {
public static void main(String args[]){

DateFormat format = new SimpleDateFormat("yyyy-MM-dd");    
Date date = null;   
String str = null;
str = "2007-1-18";         
try {   
//     date = format.parse(str);  // 输入结果  Thu Jan 18 00:00:00 CST 2007
date = java.sql.Date.valueOf(str);  // 输入结果  2007-1-18
} catch (Exception e) {   
    e.printStackTrace();   
}
System.out.println(date);
}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics