| | |
| | | package com.hx.util; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取两个时间相差分钟数 |
| | | * @param startTime 开始时间 |
| | | * @param endTime 结束时间 |
| | | * @param remainder 余数进1 |
| | | * @return 分钟 |
| | | */ |
| | | public static int differMinute(Date startTime, Date endTime,boolean remainder) { |
| | | BigDecimal sTime = new BigDecimal(startTime.getTime()); |
| | | BigDecimal eTime = new BigDecimal(endTime.getTime()); |
| | | eTime = eTime.subtract(sTime).setScale(0,RoundingMode.HALF_UP); |
| | | if(remainder){ |
| | | eTime = eTime.divide(BigDecimal.valueOf(60000.0)).setScale(0, RoundingMode.UP); |
| | | }else{ |
| | | eTime = eTime.divide(BigDecimal.valueOf(60000.0)).setScale(0, RoundingMode.DOWN); |
| | | } |
| | | return eTime.intValue(); |
| | | } |
| | | |
| | | /** |
| | | * endTime比startTime多的天数 |
| | | * @param startTime 最小时间 |
| | | * @param endTime 最大时间 |