/**
* Pass your date format and no of days for minus from current
* If you want to get previous date then pass days with minus sign
* else you can pass as it is for next date
* @param dateFormat
* @param days
* @return Calculated Date
*/
public static String getCalculatedDate(String dateFormat, int days) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat s = new SimpleDateFormat(dateFormat);
cal.add(Calendar.DAY_OF_YEAR, days);
return s.format(new Date(cal.getTimeInMillis()));
}
This function may helpful to get Next/Previous date from current date in Android.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.