代码:
/**
* 获取前一天的日期
*
* @param newFormat 当前日期
* @return
*/
public static String previousDate(String newFormat) {
String s = null;
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
Date day = sdf.parse(newFormat);
long ms = day.getTime() - 1 * 24 * 3600 * 1000L;
Date prevDay = new Date(ms);
s = sdf.format(prevDay);
System.out.println(s);
} catch (ParseException e) {
e.printStackTrace();
}
return s;
}