百度API获取某个工作日之后的时间
来源:互联网 发布:freehand 11 for mac 编辑:程序博客网 时间:2024/05/22 00:10
http://apistore.baidu.com/apiworks/servicedetail/1116.html 百度节假日shJSON返回示例 :{"20130101":2,"20130103":2,"20130105":"0","20130201":"0"}备注 :功能特点检查具体日期是否为节假日,工作日对应结果为 0, 休息日对应结果为 1, 节假日对应的结果为 2;(对应支付工资比例分别为 100%, 200% 和 300%,以方便程序计算 计算方法: 基本工资* (1+结果数值))获取具体月份下的节假日情况,只返回休息日或者节假日数据;可同时传递一个或者多个日期(月份);支持 2009 年起至2016年 中国法定节假日,以国务院发布的公告为准,随时调整及增加;http://www.gov.cn/zfwj/bgtfd.htm或http://www.gov.cn/zhengce/xxgkzl.htm参数可以以 GET 或 POST 方式传递,以 JSON 格式返回结果。用法举例检查一个日期是否为节假日 ?d=20160101检查多个日期是否为节假日 ?d=20160101,20160103,20160105,20161201获取2016年10月份节假日 ?d=201610获取2016年所有节假日 ?d=2016获取2016年1/2月份节假日 ?d=201601,201602
String httpUrl = "http://apis.baidu.com/xiaogg/holiday/holiday"; String httpArg = "d=20151001"; String jsonResult = getHolidays(httpUrl, httpArg); static String apikey = "apikey"; public static String getHolidays(String httpUrl, String httpArg) { BufferedReader reader = null; String result = null; StringBuffer sbf = new StringBuffer(); httpUrl = httpUrl + "?" + httpArg; try { URL url = new URL(httpUrl); HttpURLConnection connection = (HttpURLConnection) url .openConnection(); connection.setRequestMethod("GET"); connection.setRequestProperty("apikey", apikey); connection.connect(); InputStream is = connection.getInputStream(); reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String strRead = null; while ((strRead = reader.readLine()) != null) { sbf.append(strRead); sbf.append("\r\n"); } reader.close(); result = sbf.toString(); } catch (Exception e) { e.printStackTrace(); } return result; }
</pre><pre name="code" class="java"> public static Date getEndDay(int x) { Date date; if (x==0){ return new Date(); } String dateStr = "d="; for (int i = 0; i < 14; i++) { date = new Date() + i; dateStr += DateUtil.dateToStr(date) + ","; } String httpUrl = "http://apis.baidu.com/xiaogg/holiday/holiday"; //String httpArg = ""; JsonSlurper jsonSlurper = new JsonSlurper() def json = jsonSlurper.parseText(DateUtil.getHolidays(httpUrl, dateStr)) int count = 0; date = new Date() for (int i = 0; i < json.size(); i++) { if (json.getAt(DateUtil.dateToStr(date)).equals("0")) { count++ if (count == x) { break } } date += 1; } return date; }
传入一个工作日天数,得到一个该天数工作日后的时间
0 0
- 百度API获取某个工作日之后的时间
- 根据百度地图API,反向获取某个位置的经纬度
- 一个日本小老板某个工作日的时间纪实
- NSDate 获取当前日期之后的N个工作日
- 求某天之后的三个工作日
- 获取时间段内的工作日时间(除去周末)
- NSDate时间计算(计算某个时间之前或之后的某个时间)
- java获取当月的工作日
- 当前时间推后两个工作日的时间
- Java获取多少秒钟之后的时间
- JAVA获取某个时区的时间
- unity获取某个方法执行的时间
- 获取某个方法执行的时间
- 如何清除百度地图api的某个图层
- 获取当前时间之后的日期或者是时间
- 使用Calendar类获取某个时间指定的时间
- 用SQL获取月份的工作日
- C#获取时间段内的工作日
- Three.js 学习记录 之 几何体(一)
- js == 与 === 的区别
- 曲线拟合的几种解释
- 51nod-1067 Bash游戏 V2
- jquery和javascript的区别(常用方法比较)
- 百度API获取某个工作日之后的时间
- 基于Spark ALS的离线推荐系统实践
- c++primer 第八章IO操控流的条件状态
- 详细说明上一篇 scenario
- Vuforia开发入门二-资源介绍
- 设计模式之代理模式 Android代码分析
- 平衡搜索树中的左单旋&右单旋&双旋
- 滲透 Facebook 的思路與發現
- Ubuntu16.04 Nvidia 显卡驱动安装