Java Day of Week dayForWeek(String weeks)

Here you can find the source of dayForWeek(String weeks)

Description

day For Week

License

Open Source License

Declaration

public static List<String> dayForWeek(String weeks) throws Throwable 

Method Source Code

//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;
    }
}

Related

  1. calculateBusinessDays(Date startDate, Date endDate, int firstWeekendDay, int secondWeekendDay)
  2. Day_Of_Week(String Date, int DayCase)
  3. dayForWeek(String pTime)
  4. dayForWeek(String pTime)
  5. dayNumberOfWeek(Date date)
  6. DayOfTheWeek(Date dt)
  7. dayOfWeek(Date date)
  8. dayOfWeek(Date inDate, TimeZone timeZone)