| | |
| | | package org.jeecg.modules.mdc.util; |
| | | |
| | | |
| | | import io.swagger.models.auth.In; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | |
| | | dateList.forEach(localDate -> result.add(Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()))); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * @param smallDate |
| | | * @param bigDate |
| | | * @desc 获取两个日期之间的天数 |
| | | */ |
| | | public static Integer getDaysBetween(String smallDate, String bigDate) throws ParseException { |
| | | // 日期格式 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | // 获取两个日期的时间戳 |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(sdf.parse(smallDate)); |
| | | long smallTime = cal.getTimeInMillis(); |
| | | cal.setTime(sdf.parse(bigDate)); |
| | | long bigTime = cal.getTimeInMillis(); |
| | | // 相差的日期 |
| | | long days = (bigTime - smallTime) / (1000 * 3600 * 24); |
| | | // long转int 存在溢出情况 根据业务情况编辑catch中返回值 |
| | | try { |
| | | return Integer.parseInt(String.valueOf(days)); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | } |
| | | } |