How can I build a list of days, months, years from a calendar object in Java?

前端 未结 5 772
闹比i
闹比i 2021-01-06 14:46

I want to build a date widget for a form, which has a select list of months, days, years. since the list is different based on the month and year, i cant hard code it to 31

5条回答
  •  别那么骄傲
    2021-01-06 15:20

    Here is an example of creating a list of months:

    String[] months = new DateFormatSymbols().getMonths();
        List allMonths = new ArrayList();
        for(String singleMonth: months){
            allMonths.add(singleMonth);
        }
        System.out.println(allMonths);
    

提交回复
热议问题