Java Yesterday getYesterdayDate(int day)

Here you can find the source of getYesterdayDate(int day)

Description

get Yesterday Date

License

Open Source License

Declaration

public static String getYesterdayDate(int day) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    private static final String PATTERN = "yyyyMMdd";

    public static String getYesterdayDate(int day) {

        java.util.Calendar calendar = java.util.Calendar.getInstance();
        calendar.add(Calendar.DATE, -(day));
        java.util.Date beginDate = calendar.getTime();
        SimpleDateFormat dateFmt = new SimpleDateFormat(PATTERN);
        String yesterdayDate = dateFmt.format(beginDate);

        return yesterdayDate;
    }/*from w ww.  j av  a2  s  . c  o  m*/
}

Related

  1. getYesterDay(String pattern)
  2. getYesterday6AM()
  3. getYesterdayBegin()
  4. getYesterdayCompactTime()
  5. getYesterdayDate(Date date)
  6. getYesterdayDate(String format)
  7. getYesterdayDateAsString()
  8. getYesterdayFormat(String format)
  9. getYesterdayFormatString(String format)