Java Yesterday getYesterday()

Here you can find the source of getYesterday()

Description

get Yesterday

License

Open Source License

Declaration

public static String getYesterday() 

Method Source Code

//package com.java2s;

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

public class Main {
    public static final String _DEFAULT1 = "yyyy-MM-dd HH:mm";
    public static final String _DEFAULT4 = "yyyy-MM-dd";

    public static String getYesterday() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        long time = (date.getTime() / 1000) - 60 * 60 * 24;
        date.setTime(time * 1000);/*w ww  . j  ava  2 s .  com*/
        return sdf.format(date);
    }

    public static long getTime() {
        Date dt = new Date();
        return dt.getTime();
    }

    public static String format(Date date) {
        return formatDate(date, _DEFAULT4);
    }

    public static String formatDate(Date date) {
        return formatDate(date, _DEFAULT1);
    }

    public static String formatDate(Date date, String style) {
        return new SimpleDateFormat(style).format(date);
    }
}

Related

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