Here you can find the source of dayForWeek(String weeks)
public static List<String> dayForWeek(String weeks) throws Throwable
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.List; public class Main { public static List<String> dayForWeek(String weeks) throws Throwable { List<String> retDates = new ArrayList<String>(); int day = 1; SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd"); while (retDates.size() < 4) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, day); if (weeks.contains(String.valueOf(cal.get(Calendar.DAY_OF_WEEK) - 1))) { System.out.println(cal.get(Calendar.DAY_OF_WEEK) - 1); System.out.println(time.format(cal.getTime())); retDates.add(time.format(cal.getTime())); }//from www .j a v a2s .c o m day++; } return retDates; } }