Java Year Month getAllDate(String year_month)

Here you can find the source of getAllDate(String year_month)

Description

get All Date

License

Open Source License

Declaration

public static List<Object> getAllDate(String year_month) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

import java.util.List;

public class Main {

    public static List<Object> getAllDate(String year_month) {
        List<Object> list = new ArrayList<Object>();
        Calendar rightNow = Calendar.getInstance();
        SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM");
        try {/*from   w w  w  .ja v  a  2 s.  com*/
            rightNow.setTime(simpleDate.parse(year_month));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        int days = rightNow.getActualMaximum(Calendar.DAY_OF_MONTH);
        String date = "";
        for (int i = 1; i <= days; i++) {
            if (i < 10) {
                date = year_month + "-0" + i;
            } else {
                date = year_month + "-" + i;
            }
            list.add(date);
        }
        return list;
    }
}

Related

  1. date(final int year, final int month, final int day, final int hour, final int minute, final int second)
  2. date(int year, int month, int day)
  3. Date2Long(int year, int month, int date)
  4. encodeDateTime(int year, int month, int day, int hour, int minutes, int seconds)
  5. getAddedDate(Date date, int addYear, int addMonth, int addDay, int addHour, int addMinute, int addSecond)
  6. getBeginEndDayOfMonth(String yearMonthString)
  7. getCurrentYearMonthDay()
  8. getCurYearMonth()
  9. getDate(int year, int month, int day)