Java TimeUnit Usage getDateBefore(final Date day)

Here you can find the source of getDateBefore(final Date day)

Description

get Date Before

License

Apache License

Declaration

public static Date getDateBefore(final Date day) 

Method Source Code

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

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

import java.util.concurrent.TimeUnit;

public class Main {
    public static final long DATE = TimeUnit.DAYS.toMillis(1);

    public static Date getDateBefore(final Date day) {
        final Calendar c = Calendar.getInstance();
        c.setTime(day);// w w w  .jav a2s. com
        final int day1 = c.get(Calendar.DATE);
        c.set(Calendar.DATE, day1 - 1);

        return c.getTime();
    }
}

Related

  1. getCurrentDateTime(int offsetMin)
  2. getCurrentTimeMillis()
  3. getCurrentTimestamp()
  4. getCurrentTimestampInSeconds()
  5. getDate(final int oceanTime)
  6. getDateWithoutTime(final Calendar calendar)
  7. getDayFromTimestamp(final long unixTimestamp)
  8. getDays(final long ms)
  9. getDays(long endTs, Long lookback)