Joda
来源:互联网 发布:淘宝店铺粉丝怎么刷 编辑:程序博客网 时间:2024/06/05 03:04
/** * 计算两个日期之间相差的天数 * * @author liuchao * @since 19/10/2017 */public static int daysBetween(Date startDate, Date endDate) { Period period=new Period(startDate.getTime(),endDate.getTime(),PeriodType.days()); return period.getDays();}
/** * 按照7天一个周期把一个时间段拆分成多个时间区间 * * @author mayanjun * @since 11/11/2017 */public static Collection<WeekSplit> splitWeek(Date beginDate, Date endDate) { DateTime t1 = new DateTime(beginDate).withTime(0, 0, 0, 0); DateTime t2 = new DateTime(endDate).withTime(0, 0, 0, 0); Map<Integer, WeekSplit> splitMap = new HashMap<>(); for (DateTime ti = new DateTime(t1); ti.isBefore(t2) || ti.isEqual(t2); ti = ti.plusDays(1)) { int week = ti.getWeekOfWeekyear(); WeekSplit split = splitMap.get(week); if (split == null) { split = new WeekSplit(week); splitMap.put(week, split); } split.setDate(ti.toDate()); } return splitMap.values();}/** * 封装开始日期和截止日期 * * @author mayanjun * @since 11/11/2017 */public static class WeekSplit { Date beginDate; Date endDate; int weekOfYear; public WeekSplit(int weekOfYear) { this.weekOfYear = weekOfYear; } public void setDate(Date date) { if (beginDate == null) { beginDate = date; endDate = date; } else { endDate = date; } } public Date getBeginDate() { return beginDate; } public void setBeginDate(Date beginDate) { this.beginDate = beginDate; } public Date getEndDate() { return endDate; } public void setEndDate(Date endDate) { this.endDate = endDate; } public int getWeekOfYear() { return weekOfYear; } public void setWeekOfYear(int weekOfYear) { this.weekOfYear = weekOfYear; }}
阅读全文
0 0
- Joda
- Joda
- Joda
- Joda Study
- Joda time
- Joda-Time
- joda-time
- Joda-Time
- joda-Time
- Joda-Time
- joda time 方便快捷
- Joda-Time 简介
- Joda-Time 简介
- Joda-Time 简介
- Joda-Time 简介
- joda使用详解
- Joda--Time简介
- Joda-Time学习
- MP4文件两种格式AVC1和H264的区别及利用FFMPEG demux为h264码流事项
- ListView数据错乱--分析及解决
- 生产级Nodejs开发实践-使用连接池
- PLSQL查询数据中文乱码,显示问号
- Qt-你可以使用加农炮了
- Joda
- 使用Spring MVC统一异常处理实战
- [Azure] 使用azure cli 2.0 利用Key Vault创建自签名证书导入nginx
- Neural Networks神经网络个人小结与MATLAB实现
- 接口与实现:实验1
- 11月23日云栖精选夜读:阿里AI Labs王刚解读9小时卖出百万台的“天猫精灵”
- mt2503 [NETWORK]如何改为默认GPRS ALWAYS ON
- oracle定时执行存储过程
- css中的各种元素居中