Java Day of getDefaultOffsetDays(String strDate)

Here you can find the source of getDefaultOffsetDays(String strDate)

Description

get Default Offset Days

License

Open Source License

Declaration

public static int getDefaultOffsetDays(String strDate) throws Exception 

Method Source Code

//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");
    }
}

Related

  1. getCalendarByDay(String dayStr)
  2. getConfirmDateTimeOfDay(Date currentDate)
  3. getCurDayZero()
  4. getDataFile(int tableId, Date day)
  5. getDataTimeForwordDay(Date date, int dayNum)
  6. getDeltaDay(String day, int delta)
  7. getDeltaDays(String date)
  8. getDeltaNow(int deltaDays)
  9. getDisplayDate(final Date date, final int offsetDays)