• 用map返回一年中所有的日期


     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     }
  • 相关阅读:
    Dungeon Master(BFS)
    Shuffle'm Up(串)
    分解素因子
    Snowflake Snow Snowflakes(查找)
    求素数(素数筛选+打表)
    A simple problem(并查集判环)
    Eqs(枚举+ hash)
    Squares(枚举+set 查找)
    从控制台输入10个人的年龄放入数组,将十个人的年龄求总和
    数组
  • 原文地址:https://www.cnblogs.com/ggye99/p/13440143.html
Copyright © 2020-2023  润新知