Here you can find the source of isLowerThanMinTimeDiff(Date lastUpdate, Date now, Long minTimeDiff)
public static Boolean isLowerThanMinTimeDiff(Date lastUpdate, Date now, Long minTimeDiff)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.TimeUnit; public class Main { static final String DATEFORMAT = "yyyy-MM-dd"; public static Boolean isLowerThanMinTimeDiff(Date lastUpdate, Date now, Long minTimeDiff) { long diffinDays = diffInDays(lastUpdate, now); Boolean resultValue = minTimeDiff < diffinDays; return resultValue; }//from ww w. ja v a2s. c om public static Long diffInDays(Date date1, Date date2) { try { SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT); String lastUpdateInUTCString = sdf.format(date1); String nowInUTCString = sdf.format(date2); Date lastUpdateInUTC; lastUpdateInUTC = stringDateToDate(lastUpdateInUTCString); Date nowInUTC = stringDateToDate(nowInUTCString); long nowInUTCMilis = nowInUTC.getTime(); long lastUpdateInUTCMilis = lastUpdateInUTC.getTime(); long diff = nowInUTCMilis - lastUpdateInUTCMilis; TimeUnit tu = TimeUnit.DAYS; long diffinDays = tu.convert(diff, TimeUnit.MILLISECONDS); return diffinDays; } catch (ParseException e) { return Long.MIN_VALUE; } } public static String format(Date date) { SimpleDateFormat dateFormat = new SimpleDateFormat(DATEFORMAT); return dateFormat.format(date); } public static Date stringDateToDate(String StrDate) throws ParseException { Date dateToReturn = null; SimpleDateFormat dateFormat = new SimpleDateFormat(DATEFORMAT); try { dateToReturn = (Date) dateFormat.parse(StrDate); } catch (ParseException e) { e.printStackTrace(); } return dateToReturn; } }