使用SimpleDateFormat格式化Calendar获取到的日历c.set(2003, 7, 31, 0, 0, 0)// 2003.8.31c.add(MONTH,
使用SimpleDateFormat格式化Calendar获取到的日历
c.set(2003, 7, 31, 0, 0, 0);// 2003.8.31
c.add(MONTH, 6);// 2003-8-31>>2004.2.29
System.out.println(c.getTime());
求助怎么用SimpleDateFormat把c.getTime格式化成能看懂的?
[解决办法]
sdf.format(c.getTime())
[解决办法]
楼上正解
SimpleDateFormat dateformat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//这个字符串就是你要输出的格式,可以按自己的需要设置
System.out.println(dateformat.format(c.getTime()));
