Java Date Compare getCompareDateNum(String sDateValue1, String sDateValue2)

Here you can find the source of getCompareDateNum(String sDateValue1, String sDateValue2)

Description

get Compare Date Num

License

Apache License

Declaration

public static long getCompareDateNum(String sDateValue1, String sDateValue2) throws ParseException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**/*w ww  .j  av a 2 s . co  m*/
     * yyyy-MM-dd
     */
    public static final String DATE_FORMAT = "yyyy-MM-dd";

    public static long getCompareDateNum(String sDateValue1, String sDateValue2) throws ParseException {
        long DAY = 24L * 60L * 60L * 1000L;
        SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT);
        Date d1 = df.parse(sDateValue1);
        Date d2 = df.parse(sDateValue2);

        return ((d2.getTime() - d1.getTime()) / DAY);
    }
}

Related

  1. compDate(Date date1, Date date2)
  2. compDate4(Date date1, Date date2)
  3. getCompareDate(Date startDate, Date endDate)
  4. getCompareDate(String strDate1, String strDate2, String pFormat)
  5. getCompareDate(String strDate1, String strDate2, String pFormat)
  6. getCompareResult(String date1, String date2)
  7. isAfterOrEqual(Date date, Date toCompare)
  8. isBeforeDate(String sCompareDate)
  9. isInDate(Date date, Date compareDate)