Java small function - calculation date difference

xiaoxiao2021-03-06  40

// Get the difference in date and return to the number of days.

// Date format: 2005-01-01

// Author: meanson Wang

// email: meansonw@hotmail.com

Public static long getcomparedate (string startdate, string enddate) throws parseException {

SimpleDateFormat Formatter = New SimpleDateFormat ("YYYY-MM-DD");

Date Date1 = formatter.parse (startdate);

Date Date2 = formatter.parse (enddate);

Long L = Date2.gettime () - DATE1.GETTIME ();

Long D = L / (24 * 60 * 60 * 1000);

Return D;

}

转载请注明原文地址:https://www.9cbs.com/read-71870.html

New Post(0)