Here you can find the source of isIn(int reserveDayCount, String dateString)
public static boolean isIn(int reserveDayCount, String dateString)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static boolean isIn(int reserveDayCount, String dateString) { Date date = date(dateString); int interval = interval(date, new Date()); if (interval < 0) { return reserveDayCount > Math.abs(interval); }/*from w w w . j ava 2 s . com*/ return false; } public static Date date(String date, String format) { SimpleDateFormat dateFormat = new SimpleDateFormat(format); try { return dateFormat.parse(date); } catch (Exception e) { e.printStackTrace(); } return null; } public static Date date(String date) { return date(date, "yyyy.MM.dd"); } public static int interval(Date dateOne, Date dateTwo) { Calendar calOne = Calendar.getInstance(); calOne.setTime(dateOne); int dayOne = calOne.get(Calendar.DAY_OF_YEAR); Calendar calTwo = Calendar.getInstance(); calTwo.setTime(dateTwo); int dayTwo = calTwo.get(Calendar.DAY_OF_YEAR); return dayOne - dayTwo; } }