Java Yesterday getYesterday(Date date)

Here you can find the source of getYesterday(Date date)

Description

get Yesterday

License

Apache License

Declaration

public static Date getYesterday(Date date) 

Method Source Code


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

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getYesterday(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);/*from www  .j  av  a  2s  . c o m*/
        int day = c.get(Calendar.DATE);
        c.set(Calendar.DATE, day - 1);
        return c.getTime();
    }

    public static int get(Date date, int field) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(field);
    }
}

Related

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