Here you can find the source of getFormatYestoday(String format)
public static String getFormatYestoday(String format)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static String getFormatYestoday(String format) { return getFormatCurrentAdd(-1, format); }// w w w . j a va2s . c o m public static String getFormatCurrentAdd(int amount, String format) { Date d = getDateAdd(new Date(), amount); return getFormatDateTime(d, format); } public static Date getDateAdd(Date date, int amount) { Calendar cal = new GregorianCalendar(); cal.setTime(date); cal.add(GregorianCalendar.DATE, amount); return cal.getTime(); } public static String getFormatDateTime(Date date, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }