public static void main(String[] args) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = (Date) format.parse("2012-06-22");;
String start = format.format(startDate);
String end = format.format(addDays(startDate, 9));
System.out.println("Start : " + start);
System.out.println("End : " + end);
} catch (Exception e) {
e.printStackTrace();
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = (Date) format.parse("2012-06-22");;
String start = format.format(startDate);
String end = format.format(addDays(startDate, 9));
System.out.println("Start : " + start);
System.out.println("End : " + end);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Date addDays(Date date, int days)
{
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, days);
return cal.getTime();
}
No comments:
Post a Comment