Here you can find the source of getFormerDate(String dateTime)
public static String getFormerDate(String dateTime) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getFormerDate(String dateTime) throws ParseException { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); long dif = df.parse(dateTime).getTime() - 86400 * 1000; Date date = new Date(); date.setTime(dif);/* ww w. j a va 2s. co m*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(date); } }