| | |
| | | /** |
| | | * 获取两日期之间间隔的天数 |
| | | * |
| | | * @param smdate |
| | | * 较小的时间 |
| | | * @param bdate |
| | | * 较大的时间 |
| | | * @param smdate 较小的时间 |
| | | * @param bdate 较大的时间 |
| | | * @return 相差天数 |
| | | */ |
| | | public static int daysBetween(Date smdate, Date bdate) { |
| | |
| | | result = result + hourStr; |
| | | } |
| | | if (min!=0){ |
| | | if (day == 0) { |
| | | result = result + minStr; |
| | | } |
| | | } |
| | | if (second!=0){ |
| | | if (day == 0 && hour == 0) { |
| | | result = result + secondStr; |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public static Date fromLocalDateTime(LocalDateTime ldt){ |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | ZonedDateTime zdt = ldt.atZone(zoneId); |
| | | Date date = Date.from(zdt.toInstant()); |
| | | return date ; |
| | | } |
| | | |
| | | public static void main(String[] args) throws ParseException { |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |