接到个需求需要区分工作日和非工作日,因此在网上找了个免费的接口: (https://tool.bitefu.net/jiari/)用来测试获取相应日期信息。
接口开发人员不易,请尽量付费使用!!!

这个接口参数d输入yyyyMMdd格式的日期参数,将返回工作日(0)、休息日(1)和节假日(2)三种状态码:

请求样例:https://tool.bitefu.net/jiari/?d=20191001
返回结果:2
请求样例:https://tool.bitefu.net/jiari/?d=20191006
返回结果:1
请求样例:https://tool.bitefu.net/jiari/?d=20191008
返回结果:0

该接口也可输入yyyyMM或者yyyy参数(请自行测试),接口详情请参考其官方文档。下面为简单测试demo获取2019年全年节假日信息:

@Test
public void testHolidayGet() {// https://tool.bitefu.net/jiari/?d=20191014//LocalDate localDate = LocalDate.now();LocalDate localDate = LocalDate.of(2018, 12, 31);DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");for (int i = 0; i <= 365; i++) {localDate = localDate.plusDays(1);String yyyyMMdd = localDate.format(dateTimeFormatter);String url = "https://tool.bitefu.net/jiari/?d=" + yyyyMMdd;RestTemplate restTemplate = new RestTemplate();ResponseEntity<Integer> res = restTemplate.getForEntity(url, Integer.class);try {Thread.sleep(500);if (res.getBody() != null) {if (res.getBody() == 0) {System.out.println(yyyyMMdd + " is weekday type=" + res.getBody());} else {System.out.println(yyyyMMdd + " is holiday type=" + res.getBody());}} else {System.out.println(yyyyMMdd + "get failed");}} catch (InterruptedException e) {e.printStackTrace();}}
}

另附上2019年非工作日日期:

20190101 is holiday type=2
20190105 is holiday type=1
20190106 is holiday type=1
20190112 is holiday type=1
20190113 is holiday type=1
20190119 is holiday type=1
20190120 is holiday type=1
20190126 is holiday type=1
20190127 is holiday type=120190204 is holiday type=1
20190205 is holiday type=2
20190206 is holiday type=2
20190207 is holiday type=2
20190208 is holiday type=1
20190209 is holiday type=1
20190210 is holiday type=1
20190216 is holiday type=1
20190217 is holiday type=1
20190223 is holiday type=1
20190224 is holiday type=120190302 is holiday type=1
20190303 is holiday type=1
20190309 is holiday type=1
20190310 is holiday type=1
20190316 is holiday type=1
20190317 is holiday type=1
20190323 is holiday type=1
20190324 is holiday type=1
20190330 is holiday type=1
20190331 is holiday type=120190405 is holiday type=2
20190406 is holiday type=1
20190407 is holiday type=1
20190413 is holiday type=1
20190414 is holiday type=1
20190420 is holiday type=1
20190421 is holiday type=1
20190427 is holiday type=120190501 is holiday type=2
20190502 is holiday type=1
20190503 is holiday type=1
20190504 is holiday type=1
20190511 is holiday type=1
20190512 is holiday type=1
20190518 is holiday type=1
20190519 is holiday type=1
20190525 is holiday type=1
20190526 is holiday type=120190601 is holiday type=1
20190602 is holiday type=1
20190607 is holiday type=2
20190608 is holiday type=1
20190609 is holiday type=1
20190615 is holiday type=1
20190616 is holiday type=1
20190622 is holiday type=1
20190623 is holiday type=1
20190629 is holiday type=1
20190630 is holiday type=120190706 is holiday type=1
20190707 is holiday type=1
20190713 is holiday type=1
20190714 is holiday type=1
20190720 is holiday type=1
20190721 is holiday type=1
20190727 is holiday type=1
20190728 is holiday type=120190803 is holiday type=1
20190804 is holiday type=1
20190810 is holiday type=1
20190811 is holiday type=1
20190817 is holiday type=1
20190818 is holiday type=1
20190824 is holiday type=1
20190825 is holiday type=1
20190831 is holiday type=120190901 is holiday type=1
20190907 is holiday type=1
20190908 is holiday type=1
20190913 is holiday type=2
20190914 is holiday type=1
20190915 is holiday type=1
20190921 is holiday type=1
20190922 is holiday type=1
20190928 is holiday type=120191001 is holiday type=2
20191002 is holiday type=2
20191003 is holiday type=2
20191004 is holiday type=1
20191005 is holiday type=1
20191006 is holiday type=1
20191007 is holiday type=1
20191013 is holiday type=1
20191019 is holiday type=1
20191020 is holiday type=1
20191026 is holiday type=1
20191027 is holiday type=120191102 is holiday type=1
20191103 is holiday type=1
20191109 is holiday type=1
20191110 is holiday type=1
20191116 is holiday type=1
20191117 is holiday type=1
20191123 is holiday type=1
20191124 is holiday type=1
20191130 is holiday type=120191201 is holiday type=1
20191207 is holiday type=1
20191208 is holiday type=1
20191214 is holiday type=1
20191215 is holiday type=1
20191221 is holiday type=1
20191222 is holiday type=1
20191228 is holiday type=1
20191229 is holiday type=1

2020年非工作日日期(2019年11月21日更新):

20200101 is holiday type=2
20200104 is holiday type=1
20200105 is holiday type=1
20200111 is holiday type=1
20200112 is holiday type=1
20200118 is holiday type=1
20200124 is holiday type=1
20200125 is holiday type=2
20200126 is holiday type=2
20200127 is holiday type=2
20200128 is holiday type=1
20200129 is holiday type=1
20200130 is holiday type=120200202 is holiday type=1
20200208 is holiday type=1
20200209 is holiday type=1
20200215 is holiday type=1
20200216 is holiday type=1
20200222 is holiday type=1
20200223 is holiday type=1
20200229 is holiday type=120200301 is holiday type=1
20200307 is holiday type=1
20200308 is holiday type=1
20200314 is holiday type=1
20200315 is holiday type=1
20200321 is holiday type=1
20200322 is holiday type=1
20200328 is holiday type=1
20200329 is holiday type=120200404 is holiday type=2
20200405 is holiday type=1
20200406 is holiday type=1
20200411 is holiday type=1
20200412 is holiday type=1
20200418 is holiday type=1
20200419 is holiday type=1
20200425 is holiday type=120200501 is holiday type=2
20200502 is holiday type=1
20200503 is holiday type=1
20200504 is holiday type=1
20200505 is holiday type=1
20200510 is holiday type=1
20200516 is holiday type=1
20200517 is holiday type=1
20200523 is holiday type=1
20200524 is holiday type=1
20200530 is holiday type=1
20200531 is holiday type=120200606 is holiday type=1
20200607 is holiday type=1
20200613 is holiday type=1
20200614 is holiday type=1
20200620 is holiday type=1
20200621 is holiday type=1
20200625 is holiday type=2
20200626 is holiday type=1
20200627 is holiday type=120200704 is holiday type=1
20200705 is holiday type=1
20200711 is holiday type=1
20200712 is holiday type=1
20200718 is holiday type=1
20200719 is holiday type=1
20200725 is holiday type=1
20200726 is holiday type=120200801 is holiday type=1
20200802 is holiday type=1
20200808 is holiday type=1
20200809 is holiday type=1
20200815 is holiday type=1
20200816 is holiday type=1
20200822 is holiday type=1
20200823 is holiday type=1
20200829 is holiday type=1
20200830 is holiday type=120200905 is holiday type=1
20200906 is holiday type=1
20200912 is holiday type=1
20200913 is holiday type=1
20200919 is holiday type=1
20200920 is holiday type=1
20200926 is holiday type=120201001 is holiday type=2
20201002 is holiday type=2
20201003 is holiday type=2
20201004 is holiday type=1
20201005 is holiday type=1
20201006 is holiday type=1
20201007 is holiday type=1
20201008 is holiday type=1
20201011 is holiday type=1
20201017 is holiday type=1
20201018 is holiday type=1
20201024 is holiday type=1
20201025 is holiday type=1
20201031 is holiday type=120201101 is holiday type=1
20201107 is holiday type=1
20201108 is holiday type=1
20201114 is holiday type=1
20201115 is holiday type=1
20201121 is holiday type=1
20201122 is holiday type=1
20201128 is holiday type=1
20201129 is holiday type=120201205 is holiday type=1
20201206 is holiday type=1
20201212 is holiday type=1
20201213 is holiday type=1
20201219 is holiday type=1
20201220 is holiday type=1
20201226 is holiday type=1
20201227 is holiday type=1

java使用免费日期API获取当年节假日相关推荐

  1. 日期转换工具+获取当年节假日信息 很简单

    //封装成json 自带的JSON.stringify()会崩溃不知道为什么 function Arr2Json(arr) {var str = "{";var i = 1;for ...

  2. Spring Boot和Feign中使用Java 8时间日期API(LocalDate等)的序列化问题

    LocalDate. LocalTime. LocalDateTime是Java 8开始提供的时间日期API,主要用来优化Java 8以前对于时间日期的处理操作.然而,我们在使用Spring Clou ...

  3. 第三方免费开放API 获取用户IP 并查询其地理位置

    需求:有一个项目是微信公众号,属于汽车服务.当车主在填写车主资料或者车辆认证时,需要填写车牌号或者车架号:车牌号需要选择省,为了方便用户操作,所以想自动定位默认省,如下图: 我查询了一些博客,找到了一 ...

  4. feign 序列化_Spring Boot和Feign中使用Java 8时间日期API(LocalDate等)的序列化问题...

    LocalDate.LocalTime.LocalDateTime是Java 8开始提供的时间日期API,主要用来优化Java 8以前对于时间日期的处理操作.然而,我们在使用Spring Boot或使 ...

  5. java取昨天日期_Java 获取昨天日期方法总结

    获取昨天日期用于判断时间数据是否所属昨日区间值,Java中java.util.Date类 new Date() 获取当前日期,具体代码如下:Date as = new Date(); SimpleDa ...

  6. java 获取光标_如何在java中使用Windows API获取当前鼠标光标类型?

    这在Win7上对我很有用.该脚本使用Python,但应该很容易翻译成任何其他语言.当然,它仅在相应的应用程序不使用自定义游标时才有效: from win32con import IDC_APPSTAR ...

  7. 【转】Java 8新特性(四):新的时间和日期API

    Java 8另一个新增的重要特性就是引入了新的时间和日期API,它们被包含在java.time包中.借助新的时间和日期API可以以更简洁的方法处理时间和日期. 在介绍本篇文章内容之前,我们先来讨论Ja ...

  8. java获取经纬度_java调用高德地图api获取某个位置的经纬度

    java调用高德地图api获取经纬度的方法,废话少说,直接上代码: import com.fasterxml.jackson.databind.JsonNode; import com.ning.ht ...

  9. java获取时间的各种风格_Java8新特性之新日期API

    早期的日期 API 在早期也就是 Java 8 之前,JDK 原生比较有名的有两个类: Date 类 Calendar 类 这两个类相对来说用起来是比较困难的,之前我们往往是用的第三方的库. 新日期 ...

最新文章

  1. HDU1443(约瑟夫环问题)
  2. 顶级项目管理工具 Top 10
  3. 任意角度人脸检测pcn
  4. 【Linux】10.安装和开启ftp服务
  5. [6] 测试用例管理工具的需求整理
  6. video标签 添加视频
  7. java开发中准则怎么写_Java开发中通用的方法和准则20条
  8. linux之expect
  9. 内存图片IOS app启动动画的实现
  10. vue-router 修改或添加新参数
  11. 东南大学计算机考研数学教材,考东南大学计算机的看这里,双非学长逆袭!
  12. php.ini gd_php开启GD库实现方法
  13. mui 框架图片预览
  14. Object 转int
  15. react 父组件数据更新 触发 子组件重新渲染
  16. Longest Palindrome
  17. 认同和确定性矩阵(Ralph Stacey's Agreement and Certainty Matrix)-译
  18. 在 PDF 中添加文本的 3 种简单方法
  19. 什么牌子的蓝牙耳机音质好?适合听歌的高音质蓝牙耳机推荐
  20. c语言计算机图形来画八分画圆,计算机图形学:中点画圆算法

热门文章

  1. Xcode 禁用indexing
  2. 变量命名神器Codelf
  3. 网络爬虫的“盗亦有道”
  4. winform使用CefSharp嵌入浏览器
  5. pthread_cond_wait和pthread_cond_signal函数详解
  6. 曾国藩:凡读书,不必苦求强记
  7. 几种数据增强:Mixup,Cutout,CutMix 和yolov4中的 Mosaic
  8. canvas基础简单易懂教程(完结,多图)
  9. java中隐函数求导法则_隐函数求导的三种方法
  10. 解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin