Here you can find the source of addDay(String data)
public static String addDay(String data)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String addDay(String data) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar cd = Calendar.getInstance(); try {/* w w w . j a v a 2 s. c o m*/ cd.setTime(sdf.parse(data)); cd.add(5, 1); } catch (ParseException e) { e.printStackTrace(); } return sdf.format(cd.getTime()); } public static String addDay(int add) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar cd = Calendar.getInstance(); cd.setTime(new Date()); cd.add(5, add); return sdf.format(cd.getTime()); } public static String addDay(String data, int add) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar cd = Calendar.getInstance(); try { cd.setTime(sdf.parse(data)); cd.add(5, add); } catch (ParseException e) { e.printStackTrace(); } return sdf.format(cd.getTime()); } public static String format(Date date, String format) { String result = ""; try { if (date != null) { DateFormat dateFormat = new SimpleDateFormat(format); result = dateFormat.format(date); } } catch (Exception localException) { } return result; } public static String format(Date date) { return format(date, "yyyy-MM-dd"); } public static String getTime(Date date) { return format(date, "HH:mm:ss"); } }