public static Tuple2<String, String> getDateScope(String batchNo,
String dateScope, FlagScope flagScope) {
#batchNo 日期,dataScope 时间间隔"1",flagScope 按月或是按天
if (flagScope == null) {
return Tuple.tuple(null, null);
}
int end = 0;
int start = 0;
if (StringUtils.isNumeric(dateScope)) {
start = StringUtils.parseInteger(dateScope);
end = start - 1;
} else {
dateScope.replaceAll("[^0-9]", ",");
String[] monthes = dateScope.split(",");
List<Integer> monthPair = new ArrayList<Integer>();
for (String m : monthes) {
if (StringUtils.isNumeric(m)) {
int temp = StringUtils.parseInteger(m);
monthPair.add(temp);
}
}
if (monthPair.size() != 2) {
throw new IllegalArgumentException("dateScope");
}
end = monthPair.get(0);
start = monthPair.get(1);
if (end > start) {
int temp = end;
end = start;
start = temp;
}
}
String startDate = null;
String endDate = null;
if (start > 0) {
startDate = DateUtils.getDateFormat(batchNo, start,
flagScope.getFlag());
endDate = DateUtils
.getDateFormat(batchNo, end, flagScope.getFlag());
}
Tuple2<String, String> scope = Tuple.tuple(startDate, endDate);
return scope;
}
}
获取一段时间的起止时间
最新推荐文章于 2021-12-06 11:07:21 发布