Java Day getDays(Date day, int preDays, String format)

Here you can find the source of getDays(Date day, int preDays, String format)

Description

get Days

License

Apache License

Declaration

public static List<String> getDays(Date day, int preDays, String format) 

Method Source Code

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

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

import java.util.List;

public class Main {
    public static List<String> getDays(Date day, int preDays, String format) {
        List<String> returnValue = new ArrayList<String>();
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Calendar c = Calendar.getInstance();
        c.setTime(day);/*from w  ww  .j  a va 2s  . c om*/
        for (int i = 0; i < preDays; i++) {
            c.add(Calendar.DAY_OF_YEAR, -1);
            /*
             * while(c.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY ||
             * c.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY) {
             * c.add(Calendar.DAY_OF_YEAR, -1); }
             */
            returnValue.add(new String(sdf.format(c.getTime())));
        }
        return returnValue;
    }
}

Related

  1. getDayOfDate(Date date)
  2. getDayOffset(String date, int offset, String format)
  3. getDayofTheDate(Date d1)
  4. getDAYOFWEEK(String strDate)
  5. getDayRange(String bday, String eday)
  6. getDays(Date sd, Date ed)
  7. getDays(String yyyy)
  8. getDaysAgo(int interval)
  9. getDaysByYearMonth(String ym)