Java Yesterday getYesterday()

Here you can find the source of getYesterday()

Description

get Yesterday

License

Apache License

Declaration

public static String getYesterday() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    public static String getYesterday() {
        Date cDate = new Date();
        cDate.setTime(cDate.getTime() - 24 * 3600 * 1000);
        SimpleDateFormat cSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return cSimpleDateFormat.format(cDate);
    }//from w  w  w  .ja v  a  2s.c  o  m

    /**
     * Returns a string the represents the passed-in date parsed according to
     * the passed-in format. Returns an empty string if the date or the format
     * is null.
     **/
    public static String format(Date aDate, SimpleDateFormat aFormat) {
        if (aDate == null || aFormat == null) {
            return "";
        }
        synchronized (aFormat) {
            return aFormat.format(aDate);
        }
    }
}

Related

  1. getYesterday()
  2. getYesterday()
  3. getYesterday()
  4. getYesterday()
  5. getYesterDay()
  6. getYesterday(Date date)
  7. getYesterday(Date date, Boolean isBefore, int interval)
  8. getYesterDay(String pattern)
  9. getYesterday6AM()