Java Date Now getCurrentWeekDays()

Here you can find the source of getCurrentWeekDays()

Description

get Current Week Days

License

Open Source License

Declaration


public static List<String> getCurrentWeekDays() 

Method Source Code


//package com.java2s;

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

import java.util.List;

public class Main {
    /**/*w  w w  .j  a  v  a 2s.com*/
     * @Title: getCurrentWeekDays
     * @Description: TODO
     * @author alterhu2020@gmail.com
     * @param @return
     * @return List<String> return type
     * @throws
     */

    public static List<String> getCurrentWeekDays() {
        List<String> currentweek = new ArrayList<String>();
        for (int kindex = 1; kindex <= 7; kindex++) {
            Calendar c = Calendar.getInstance();
            int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
            if (day_of_week == 0)
                day_of_week = 7;
            c.add(Calendar.DATE, -day_of_week + kindex);
            String currentday = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
            currentweek.add(currentday);
        }
        return currentweek;
    }
}

Related

  1. getCurrentUTCSeconds(Date current)
  2. getCurrentUTCString()
  3. getCurrentUTCTime()
  4. getCurrentUTCTimeAsString()
  5. getCurrentWeekDay(Date date, int day)
  6. getCurrentWeekFirst()
  7. getCurrentYear()
  8. getCurrentYearBegDate(Date date)
  9. getCurrentYMDDate()