SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");Date date = df.parse("20051231"); date.setTime(date.getTime()+8640000);//8640000是一天的数值大小,也可能是5个0System.out.println(date);
public String getDate(String date, int addday) throws Exception { SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");Date d = sf.parse(date); Calendar c = Calendar.getInstance(); c.setTime(d); c.add(Calendar.DAY, addday);d = c.getTime(); return sf.format(d) ; }
date.setTime(date.getTime()+8640000);//8640000是一天的数值大小,也可能是5个0System.out.println(date);
->java.text.Format
->java.text.DateFormat
->java.text.SimpleDateFormat自己查JKD去,在子类SimpleDateFormat下面有方法可以实现。
{
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");Date d = sf.parse(date);
Calendar c = Calendar.getInstance();
c.setTime(d);
c.add(Calendar.DAY, addday);d = c.getTime();
return sf.format(d) ;
}