Here you can find the source of getTodayIntevalDays(String date)
public static long getTodayIntevalDays(String date)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long getTodayIntevalDays(String date) { try {//from w w w . jav a2 s. co m Date currentDate = new Date(); SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date theDate = myFormatter.parse(date); long days = (currentDate.getTime() - theDate.getTime()) / (24 * 60 * 60 * 1000); return days; } catch (Exception ee) { return 0l; } } public static long getTodayIntevalDays(Date date) { try { Date currentDate = new Date(); long days = (currentDate.getTime() - date.getTime()) / (24 * 60 * 60 * 1000); return days; } catch (Exception ee) { return 0l; } } public static Date parse(String strDate, String pattern) throws ParseException { try { return getFormatter(pattern).parse(strDate); } catch (ParseException pe) { throw new ParseException("Method parse in Class DateUtil err: parse strDate fail.", pe.getErrorOffset()); } } private static SimpleDateFormat getFormatter(String parttern) { return new SimpleDateFormat(parttern); } }