整体逻辑
final List<RDSfzrdxxbVO> rdsfzrdxxbVOList = RDSfzrdxxUtils.queryNsrSfzrdxxA1(rdcxvo);
final SwordSortUtils.SortDescription ascDm = new SwordSortUtils.SortDescription("rdyxqq", SwordSortUtils.OrderType.ASC);
final SwordSortUtils.SortDescription[] asc = { ascDm };
SwordSortUtils.sortBeanList(rdsfzrdxxbVOList, asc);
final Calendar calendar = Calendar.getInstance();
Date sksqq = skssqq;
final Date sksqz = skssqz;
String reCode = "";
for (RDSfzrdxxbVO rdSfzrdxxbVO : rdsfzrdxxbVOList) {
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
final Date startDate = simpleDateFormat.parse(rdSfzrdxxbVO.getRdyxqq());
final Date endDate = simpleDateFormat.parse(rdSfzrdxxbVO.getRdyxqz());
if (sksqq.after(startDate) || sksqq.equals(startDate)) {
calendar.setTime(endDate);//设置开始改变日期的世界
calendar.add(calendar.DATE,1);//设置改变日期的形式
//往后推一天,满足下一段有效期起。进行下一阶段区间覆盖
sksqq = calendar.getTime();
//判断区间结束日期是否被覆盖
if (sksqq.after(sksqz) || sksqq.equals(sksqz)) {
reCode = "1";
} else {
reCode = "0";
}
} else {
reCode = "0";
}
}
return reCode;
分段解析
做一次顺序排序
final SwordSortUtils.SortDescription ascDm = new SwordSortUtils.SortDescription("rdyxqq", SwordSortUtils.OrderType.ASC);
final SwordSortUtils.SortDescription[] asc = { ascDm };
SwordSortUtils.sortBeanList(rdsfzrdxxbVOList, asc);
获取数据为String需要转化为Date型
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
final Date startDate = simpleDateFormat.parse(rdSfzrdxxbVO.getRdyxqq());
final Date endDate = simpleDateFormat.parse(rdSfzrdxxbVO.getRdyxqz());
通过结束日期覆盖期起日期进行区间覆盖
if (sksqq.after(startDate) || sksqq.equals(startDate)) {
calendar.setTime(endDate);//设置开始改变日期的世界
calendar.add(calendar.DATE,1);//设置改变日期的形式
//往后推一天,满足下一段有效期起。进行下一阶段区间覆盖
sksqq = calendar.getTime();
//判断区间结束日期是否被覆盖
if (sksqq.after(sksqz) || sksqq.equals(sksqz)) {
reCode = "1";
}