首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

JAVA 取下个月

2012-12-22 
JAVA 取上个月SimpleDateFormat sdf new SimpleDateFormat(yyyy-MM)Calendar calendar Calendar.ge

JAVA 取上个月

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");Calendar calendar = Calendar.getInstance();Date curDate = java.sql.Date.valueOf("2012-12-22");calendar.setTime(curDate);//取得现在时间System.out.println(sdf.format(curDate));//取得上一个时间calendar.set(Calendar.MONDAY, calendar.get(Calendar.MONDAY) - 1);//取得上一个月的下一天calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1);System.out.println(sdf.format(calendar.getTime()));

热点排行