读书人

JAVA 取下个月

发布时间: 2012-12-22 12:05:06 作者: rapoo

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()));

读书人网 >编程

热点推荐