public static void main(String[] args) {
List list = getMap();
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
}
}
public static List<String> getMap() {
Map<Object, String> map = new LinkedHashMap<>();
List list = getDayByMonth(2021, 8);
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
// System.out.println(list.get(i));
map.put(list.get(i), "白班");
}
}
List list1 = new ArrayList();
list1.add(0, map);
return list1;
}
public static List<String> getDayByMonth(int yearParam, int monthParam) {
List list = new ArrayList();
Calendar aCalendar = Calendar.getInstance(Locale.CHINA);
aCalendar.set(yearParam, monthParam, 1);
int year = aCalendar.get(Calendar.YEAR);//年份
int month = aCalendar.get(Calendar.MONTH) + 1;//月份
int day = aCalendar.getActualMaximum(Calendar.DATE);
for (int i = 1; i <= day; i++) {
String aDate = null;
if (month < 10 && i < 10) {
aDate = String.valueOf(year) + "-0" + month + "-0" + i;
}
if (month < 10 && i >= 10) {
aDate = String.valueOf(year) + "-0" + month + "-" + i;
}
if (month >= 10 && i < 10) {
aDate = String.valueOf(year) + "-" + month + "-0" + i;
}
if (month >= 10 && i >= 10) {
aDate = String.valueOf(year) + "-" + month + "-" + i;
}
list.add(aDate);
}
return list;
}