import java.util.Date;
public class test1111
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
java.util.Calendar c = new java.util.GregorianCalendar();
c.setTime(new Date());
System.out.println("Year:Month:Day"+c.get(c.YEAR)+"-"+(c.get(c.MONTH)+1)+"-"+c.get(c.DATE));
c.add(c.MONTH,-1);
System.out.println("Year:Month:Day"+c.get(c.YEAR)+"-"+(c.get(c.MONTH)+1)+"-"+c.get(c.DATE));
}
}
*****************************************************************************************************************
package com.ice.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateUtil {
public static String getStringDateFormat(Date date, String dateformat) {
SimpleDateFormat sf = new SimpleDateFormat(dateformat);
return sf.format(date);
}
public static Date getRMDate(Date nowdate) {
Calendar c=Calendar.getInstance();
c.setTime(nowdate);
System.out.println(DateUtil.getStringDateFormat(c.getTime(), "yyyy-MM-dd"));
c.add(c.MONTH, -1);
System.out.println(DateUtil.getStringDateFormat(c.getTime(), "yyyy-MM-dd"));
return new Date();
}
public static void main(String[] args) throws ParseException {
Date date =new Date();
DateUtil.getRMDate(date);
}
}