Here you can find the source of addDay(String currentdate, int add_day)
public static String addDay(String currentdate, int add_day)
//package com.java2s; import java.text.*; import java.util.*; public class Main { public static String addDay(String currentdate, int add_day) { GregorianCalendar gc = null; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); int year, month, day; try {/*from ww w . j ava2 s . c o m*/ year = Integer.parseInt(currentdate.substring(0, 4)); month = Integer.parseInt(currentdate.substring(5, 7)) - 1; day = Integer.parseInt(currentdate.substring(8, 10)); gc = new GregorianCalendar(year, month, day); gc.add(GregorianCalendar.DATE, add_day); return formatter.format(gc.getTime()); } catch (Exception e) { e.printStackTrace(); return null; } } public static int getTime(String sDateTime, String eDateTime) throws ParseException { SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date ssDateTime = myFormatter.parse(sDateTime); java.util.Date eeDateTime = myFormatter.parse(eDateTime); long l = (eeDateTime.getTime() - ssDateTime.getTime()); long day = l / (24 * 60 * 60 * 1000); return (int) day; } }