Here you can find the source of addDays(String dateStr, int days)
public static Date addDays(String dateStr, int days)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.*; public class Main { public static Date addDays(String dateStr, int days) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try {/*from w w w. j ava2 s . co m*/ Date date = sdf.parse(dateStr); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DATE, 15); return cal.getTime(); } catch (Exception e) { return null; } } public static String getTime() { Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateString = formatter.format(currentTime); String min; min = dateString.substring(14, 16); return min; } }