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

Calendar.DAY_OF_MONTH
Calendar c = Calendar.getInstance();

c.add(Calendar.DAY_OF_MONTH,-15);//这个能达到什么效果

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");

String payMonth = sdf.format(c.getTime());

这样做为了获取上个月的时间,我想问下为什么会达到这个效果,特别是-15什么意思,还有c.getTime()不是得到Date什么变成月份了,谢谢

------解决方案--------------------
c.add(Calendar.DAY_OF_MONTH,-15); //日期往后退15天。
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
------解决方案--------------------
DAY_OF_MONTH
public static final int DAY_OF_MONTHget 和 set 的字段数字,指示一个月中的某天。它与 DATE 是同义词。一个月中第一天的值为 1。