|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 得出两个日期之间的间隔天数 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param strFromDate | 
|---|
|  |  |  | * @param smallDate | 
|---|
|  |  |  | *            格式为yyyy-MM-dd | 
|---|
|  |  |  | * @param strToDate | 
|---|
|  |  |  | * @param bigDate | 
|---|
|  |  |  | *            格式为yyyy-MM-dd | 
|---|
|  |  |  | * @return int | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static long getBetweenDays(String strFromDate, String strToDate) { | 
|---|
|  |  |  | public static long getBetweenDays(String smallDate, String bigDate) { | 
|---|
|  |  |  | long m_intervalday = 0;// 初始化时间间隔的值为0 | 
|---|
|  |  |  | // 使用的时间格式为yyyy-MM-dd | 
|---|
|  |  |  | SimpleDateFormat m_simpledateformat = new SimpleDateFormat("yyyy-MM-dd"); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Date fromDate = m_simpledateformat.parse(strFromDate); | 
|---|
|  |  |  | Date toDate = m_simpledateformat.parse(strToDate); | 
|---|
|  |  |  | Date fromDate = m_simpledateformat.parse(smallDate); | 
|---|
|  |  |  | Date toDate = m_simpledateformat.parse(bigDate); | 
|---|
|  |  |  | m_intervalday = toDate.getTime() - fromDate.getTime();// 计算所得为微秒数 | 
|---|
|  |  |  | m_intervalday = m_intervalday / 1000 / 60 / 60 / 24;// 计算所得的天数 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | System.out.println((int)(3.222)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | System.out.println(DateUtil.getBetweenDays("2025-02-13","2025-02-15")); | 
|---|
|  |  |  | } catch (Exception ex) { | 
|---|
|  |  |  | ex.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|