日期:2014-05-20  浏览次数:20728 次

怎么样输出这种格式的日期的字符串呀?“2007-04-05"
怎么样输出这种格式的日期的字符串呀?“2007-04-05 "

------解决方案--------------------
java.text.DateFormat f=new java.util.SimpleDateFormat( "yyyy-MM-dd ");
java.util.Date d=new java.util.Date();
System.out.println(f.format(d));


自己去看看api文档,里面都!!!!!


另外看看csdn已经解决的帖子,有N多!!!!


就知道问!!!!!!!!!!


自己动手、动脑!
------解决方案--------------------
public static final String getDateString(java.util.Date aDate) {
String ret = " ";
Calendar c = Calendar.getInstance();
c.setTime(aDate);

ret = c.get(Calendar.YEAR) + "- " ;
ret = ret + addZero((c.get(Calendar.MONTH)+1) + " ", 2) + "- " ;
ret = ret + addZero((c.get(Calendar.DAY_OF_MONTH)) + " ", 2) + " " ;
ret = ret + addZero((c.get(Calendar.HOUR_OF_DAY)) + " ", 2) + ": " ;
//ret = ret + addZero((c.get(Calendar.MINUTE)) + " ", 2) + ": ";
//ret = ret + addZero((c.get(Calendar.SECOND)) + " ", 2);
return ret;
}