Here you can find the source of getDefaultOffsetDays(String strDate)
public static int getDefaultOffsetDays(String strDate) throws Exception
//package com.java2s; //License from project: GNU General Public License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static int getDefaultOffsetDays(String strDate) throws Exception { SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date param_date = fmt.parse(strDate); return getOffsetDays(param_date, new Date()); }/* ww w . j a va 2 s. c o m*/ public static int getOffsetDays(String strDate) throws Exception { SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd"); Date param_date = fmt.parse(strDate); return getOffsetDays(param_date, new Date()); } public static int getOffsetDays(Date pDate1, Date pDate2) throws Exception { return (int) ((pDate1.getTime() - pDate2.getTime()) / (1000 * 60 * 60 * 24)); } public static int getOffsetDays(String strDate, String strDate2, String pFormat) throws Exception { SimpleDateFormat fmt = new SimpleDateFormat(pFormat); SimpleDateFormat fmt2 = new SimpleDateFormat(pFormat); Date param_date1 = fmt.parse(strDate); Date param_date2 = fmt2.parse(strDate2); return getOffsetDays(param_date1, param_date2); } public static int getOffsetDays(String strDate, String strDate2) throws Exception { return getOffsetDays(strDate, strDate2, "yyyyMMdd"); } public static int getOffsetDays(int strDate, int strDate2) throws Exception { return getOffsetDays(Integer.toString(strDate), Integer.toString(strDate2), "yyyyMMdd"); } }