Commit f6ec1dcd authored by duanruiming's avatar duanruiming

[update] 代码优化-优化blocker异常

parent cac32575
...@@ -167,7 +167,9 @@ public class DateUtils { ...@@ -167,7 +167,9 @@ public class DateUtils {
public static Double getIntervalHours(String startTime, String endTime) { public static Double getIntervalHours(String startTime, String endTime) {
Date staDate = DateUtils.stringToDate(startTime, DateStyle.HH_MM_SS); Date staDate = DateUtils.stringToDate(startTime, DateStyle.HH_MM_SS);
Date endDate = DateUtils.stringToDate(endTime, DateStyle.HH_MM_SS); Date endDate = DateUtils.stringToDate(endTime, DateStyle.HH_MM_SS);
if(staDate == null || endDate == null) return null; if(staDate == null || endDate == null) {
return null;
}
BigDecimal startTimeStamp = BigDecimal.valueOf(staDate.getTime()); BigDecimal startTimeStamp = BigDecimal.valueOf(staDate.getTime());
BigDecimal endTimeStamp = BigDecimal.valueOf(endDate.getTime()); BigDecimal endTimeStamp = BigDecimal.valueOf(endDate.getTime());
BigDecimal hours = endTimeStamp.subtract(startTimeStamp).divide(new BigDecimal(1000 * 60 * 60), 2, BigDecimal.ROUND_DOWN); BigDecimal hours = endTimeStamp.subtract(startTimeStamp).divide(new BigDecimal(1000 * 60 * 60), 2, BigDecimal.ROUND_DOWN);
...@@ -809,7 +811,9 @@ public class DateUtils { ...@@ -809,7 +811,9 @@ public class DateUtils {
*/ */
public static int compareDate(Date date1, Date date2) { public static int compareDate(Date date1, Date date2) {
if(date1 == null || date2 == null) return 0; if(date1 == null || date2 == null) {
return 0;
}
if (date1.getTime() > date2.getTime()) { if (date1.getTime() > date2.getTime()) {
return 1; return 1;
} else if (date1.getTime() < date2.getTime()) { } else if (date1.getTime() < date2.getTime()) {
...@@ -830,8 +834,9 @@ public class DateUtils { ...@@ -830,8 +834,9 @@ public class DateUtils {
* @author: yinguijin * @author: yinguijin
*/ */
public static boolean isSameDate(Date d1, Date d2) { public static boolean isSameDate(Date d1, Date d2) {
if (null == d1 || null == d2) if (null == d1 || null == d2) {
return false; return false;
}
Calendar cal1 = Calendar.getInstance(); Calendar cal1 = Calendar.getInstance();
cal1.setTime(d1); cal1.setTime(d1);
Calendar cal2 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance();
...@@ -1208,7 +1213,7 @@ public class DateUtils { ...@@ -1208,7 +1213,7 @@ public class DateUtils {
end.set(Integer.valueOf(dateEnds[0]), Integer.valueOf(dateEnds[1]) - 1, Integer.valueOf(dateEnds[2])); end.set(Integer.valueOf(dateEnds[0]), Integer.valueOf(dateEnds[1]) - 1, Integer.valueOf(dateEnds[2]));
Long endTime = end.getTimeInMillis(); Long endTime = end.getTimeInMillis();
//定义一个一天的时间戳时长 //定义一个一天的时间戳时长
Long oneDay = 1000 * 60 * 60 * 24l; Long oneDay = 1000 * 60 * 60 * 24L;
Long time = startTIme; Long time = startTIme;
//循环得出 //循环得出
while (time <= endTime) { while (time <= endTime) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment