| | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.Date; |
| | | |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | |
| | | * 计算相差天数 |
| | | */ |
| | | public static int differentDaysByMillisecond(Date date1, Date date2) { |
| | | return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24))); |
| | | LocalDate d1 = date1.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | LocalDate d2 = date2.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | return (int) ChronoUnit.DAYS.between(d1, d2); |
| | | } |
| | | |
| | | /** |