package com.zhang.test;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
public class Test {
public static Date addDate(Date d,long day) throws ParseException {
long time = d.getTime();
day = day*24*60*60*1000;
time+=day;
return new Date(time);
}
/**
* @param args
*/
public static void main(String[] args) {
/*
java.util.Date dt=new java.util.Date();
System.out.println(dt); //输出结果是:Wed Aug 10 11:29:11 CST 2005
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
System.out.print(sdf.format(dt) + 12);
*/
Date d = new Date();
Date newDate = addDate(d, 12);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(dateFormat.format(d));
System.out.println(dateFormat.format(newDate));
}
}