Java Day getDayBefore(Date date)

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

Description

get Day Before

License

Open Source License

Declaration

public static String getDayBefore(Date date) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    private static final String DEFAULT_PATTERN = "yyyy-MM-dd";

    public static String getDayBefore(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);/*from www .  jav a 2 s  .co m*/
        cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1);
        return pattern(DEFAULT_PATTERN, cal.getTime());
    }

    public static String pattern(String pattern, Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(date);
    }
}

Related

  1. getDAY(String strDate)
  2. getDay(String string)
  3. getDay(String tempdat, Locale locale)
  4. getDayAfter(String dateformat, String day, int filed, int delta)
  5. getDayAfterTommorrowsDateFne()
  6. getDayBegin(Date date)
  7. getDayBetween(String firstDay, String secondDay)
  8. getDayDate(String date, String formatFormat)
  9. getDayDesc(Date arg)