Here you can find the source of getDays(Date day, int preDays, String format)
public static List<String> getDays(Date day, int preDays, String format)
//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; } }