获取指定年份的法定节假日
生活随笔
收集整理的这篇文章主要介绍了
获取指定年份的法定节假日
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
节假日不应该多点吗???????
public static List<Map<String,Object>> getStatutoryCalendar(Integer year){List<Map<String,Object>> listmap;try {listmap= new ArrayList<>();String url="http://opendata.baidu.com/api.php?query="+year+"&resource_id=6018&format=json";JSONObject result=JSONObject.fromObject(HttpUtil.postData(url,"","application/json"));JSONArray data=JSONArray.fromObject(result.get("data"));SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");for(int i=0;i<data.size();i++){JSONArray holidaylist=data.getJSONObject(i).getJSONArray("holiday");for(int j=0;j<holidaylist.size();j++){JSONObject holiday=holidaylist.getJSONObject(j);JSONArray list=holiday.getJSONArray("list");for(int n=0;n<list.size();n++){Map<String,Object> map=new HashMap<>();JSONObject dateobjchild=list.getJSONObject(n);//dateobjchild.get("status") 返回1和2 1假日 2周六日上班,把2的设置为0(上班)Object status="1".equals(dateobjchild.get("status"))?dateobjchild.get("status"):"0";if(holiday.get("festival").equals(dateobjchild.get("date"))){map.put("year",year);map.put("date",sf.format(sf.parse(holiday.get("festival").toString())));map.put("status",status);map.put("name",holiday.get("name"));}else{map.put("year",year);map.put("date",sf.format(sf.parse(dateobjchild.get("date").toString())));map.put("status",status);//1假日 2周六日上班}listmap.add(map);}}}}catch (Exception e) {listmap=null;logger.error("从百度同步法定节假日失败!");e.printStackTrace();}deWeight(listmap);return listmap;}总结
以上是生活随笔为你收集整理的获取指定年份的法定节假日的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: ACM比赛环境-Mac visual s
- 下一篇: iPhone14和Mate 50先后“亮