博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java获取两个日期之间的工作日天数
阅读量:4120 次
发布时间:2019-05-25

本文共 627 字,大约阅读时间需要 2 分钟。

参数:开始日期,结束日期 String

返回值:天数 int

@SuppressWarnings("deprecation")public int getDutyDays(String strStartDate,String strEndDate) {SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");Date startDate=null;Date endDate = null;try {startDate=df.parse(strStartDate);endDate = df.parse(strEndDate);} catch (ParseException e) {System.out.println("非法的日期格式,无法进行转换");e.printStackTrace();}int result = 0;while (startDate.compareTo(endDate) <= 0) {if (startDate.getDay() != 6 && startDate.getDay() != 0)result++;startDate.setDate(startDate.getDate() + 1);}return result;}
转自【http://www.blogjava.net/pcenshao/archive/2011/11/18/364149.html】

转载地址:http://dwnpi.baihongyu.com/

你可能感兴趣的文章
设计模式六大原则(6):开闭原则
查看>>
阿里面试总结--JAVA
查看>>
Servlet的生命周期
查看>>
JAVA八大经典书籍,你看过几本?
查看>>
《读书笔记》—–书单推荐
查看>>
【设计模式】—-(2)工厂方法模式(创建型)
查看>>
有return的情况下try catch finally的执行顺序(最有说服力的总结)
查看>>
String s1 = new String("abc"); String s2 = ("abc");
查看>>
JAVA数据类型
查看>>
Xshell 4 入门
查看>>
SoapUI-入门
查看>>
Oracle -常用命令
查看>>
JAVA技术简称
查看>>
ORACLE模糊查询优化浅谈
查看>>
2016——个人年度总结
查看>>
2017——新的开始,加油!
查看>>
【Python】学习笔记——-6.2、使用第三方模块
查看>>
【Python】学习笔记——-7.0、面向对象编程
查看>>
【Python】学习笔记——-7.2、访问限制
查看>>
【Python】学习笔记——-7.3、继承和多态
查看>>