Commit f6ec1dcd authored by duanruiming's avatar duanruiming

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

parent cac32575
......@@ -167,7 +167,9 @@ public class DateUtils {
public static Double getIntervalHours(String startTime, String endTime) {
Date staDate = DateUtils.stringToDate(startTime, 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 endTimeStamp = BigDecimal.valueOf(endDate.getTime());
BigDecimal hours = endTimeStamp.subtract(startTimeStamp).divide(new BigDecimal(1000 * 60 * 60), 2, BigDecimal.ROUND_DOWN);
......@@ -809,7 +811,9 @@ public class DateUtils {
*/
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()) {
return 1;
} else if (date1.getTime() < date2.getTime()) {
......@@ -830,8 +834,9 @@ public class DateUtils {
* @author: yinguijin
*/
public static boolean isSameDate(Date d1, Date d2) {
if (null == d1 || null == d2)
if (null == d1 || null == d2) {
return false;
}
Calendar cal1 = Calendar.getInstance();
cal1.setTime(d1);
Calendar cal2 = Calendar.getInstance();
......@@ -1208,7 +1213,7 @@ public class DateUtils {
end.set(Integer.valueOf(dateEnds[0]), Integer.valueOf(dateEnds[1]) - 1, Integer.valueOf(dateEnds[2]));
Long endTime = end.getTimeInMillis();
//定义一个一天的时间戳时长
Long oneDay = 1000 * 60 * 60 * 24l;
Long oneDay = 1000 * 60 * 60 * 24L;
Long time = startTIme;
//循环得出
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