1 public static Map<String, String> getDayOfYear(){ 2 Map<String,String> map=new HashMap<String,String>(); 3 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); 4 List<String> fullDayList = new ArrayList<String>(32); 5 Calendar ca = Calendar.getInstance(); 6 ca.clear(); 7 ca.set(Calendar.YEAR, 2019); 8 ca.set(Calendar.MONTH,0); 9 ca.set(Calendar.DAY_OF_MONTH, 0); 10 int count = ca.getActualMaximum(Calendar.DAY_OF_YEAR); 11 for (int j = 1; j <= count ; j++) { 12 fullDayList.add(sdf.format(ca.getTime())); 13 ca.add(Calendar.DAY_OF_MONTH,1); 14 //星期 15 Locale.setDefault(Locale.CHINA); 16 String[] dayStringOfWeek = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"}; 17 int d = ca.get(Calendar.DAY_OF_WEEK); 18 String day=sdf.format(ca.getTime())+dayStringOfWeek[d-1]; 19 map.put("time", day); 20 for (Object value : map.values()) { 21 System.out.println(value); 22 } 23 } 24 return map; 25 } 26 public static void main(String[] args){ 27 Map<String, String> map=getDayOfYear(); 28 }