Here you can find the source of diffOfDate(String begin, String end)
public static boolean diffOfDate(String begin, String end) throws Exception
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static boolean diffOfDate(String begin, String end) throws Exception { try {// ww w . ja va 2 s . c o m SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date thisdate = formatter.parse(formatter.format(new Date())); Date beginDate = formatter.parse(begin); Date endDate = formatter.parse(end); if ((thisdate.equals(beginDate) || thisdate.after(beginDate)) && (thisdate.equals(endDate) || thisdate.before(endDate))) { return true; } else { return false; } } catch (Exception e) { e.printStackTrace(); } return false; } }