Android examples for java.util:Day
get Yesterday in yyyy.MM.dd format
import java.text.DateFormat; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.regex.Pattern; public class Main{ public static String getYesterday() { SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd", Locale.US);/*from w ww. ja v a 2s . c o m*/ Date yesterday = new Date(); yesterday.setTime(yesterday.getTime() - ((long) 1000 * 60 * 60 * 24)); String dTime = formatter.format(yesterday); return dTime; } }