Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class Main {
    public static List<Integer> getAllDayInMonth(int month, int year) {
        List<Integer> listDate = new ArrayList<Integer>();

        Calendar calendar = Calendar.getInstance();
        calendar.set(year, month, 1);
        calendar.clear(Calendar.HOUR);
        calendar.clear(Calendar.MINUTE);
        calendar.clear(Calendar.SECOND);
        int totalDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

        for (int i = 1; i <= totalDays; i++) {
            listDate.add(i);
        }
        return listDate;
    }
}