Java Yesterday yesterday(int daybefore, String pattern)

Here you can find the source of yesterday(int daybefore, String pattern)

Description

yesterday

License

Open Source License

Declaration

public static String yesterday(int daybefore, String pattern) 

Method Source Code


//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static String yesterday(int daybefore, String pattern) {
        Calendar cal = yesterday(daybefore);
        return new SimpleDateFormat(pattern).format(cal.getTime());
    }/*from w  w w .j av  a  2  s.  c o m*/

    public static Calendar yesterday(int daybefore) {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -(daybefore + 1));
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal;
    }
}

Related

  1. yesterday()
  2. yesterday()
  3. yesterday()
  4. yesterday()
  5. yesterday(Date date)
  6. yesterdayDate()
  7. yesterdayDate3()