+ -
当前位置:首页 → 问答吧 → 日期格式化

日期格式化

时间:2011-10-20

来源:互联网

Date date = new Date(2011, 3, 7);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss");
System.out.println(formatter.format(date));
 
//3911-04-07 00:04:00

输出的结果年怎么是3911?

作者: wenle1229   发布时间: 2011-10-20

怎么把2011年指定为起始时间了,肯定年分要很大,我看api文档里这个带参函数目前不用了吧

作者: corchen   发布时间: 2011-10-20

Date date = new Date(2011, 3, 7);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss");
System.out.println(formatter.format(new Date()));

作者: genglong1024   发布时间: 2011-10-20

不看文档
  year - the year minus 1900.

废弃的构造方法。

作者: huntor   发布时间: 2011-10-20

注意了,大小写是有影响的

yyyy-MM-dd HH:mm:ss

作者: chenchenyangll   发布时间: 2011-10-20