Android Utililty Methods Date Interval Get

List of utility methods to do Date Interval Get

Description

The list of methods to do Date Interval Get are organized into topic(s).

Method

intgetInterval(String beginMonth, String endMonth)
get Interval
int intBeginYear = Integer.parseInt(beginMonth.substring(0, 4));
int intBeginMonth = Integer.parseInt(beginMonth
        .substring(beginMonth.indexOf("-") + 1));
int intEndYear = Integer.parseInt(endMonth.substring(0, 4));
int intEndMonth = Integer.parseInt(endMonth.substring(endMonth
        .indexOf("-") + 1));
return ((intEndYear - intBeginYear) * 12)
        + (intEndMonth - intBeginMonth) + 1;
...
doublegetIntervalDays(Date minDate, Date maxDate)
get Interval Days
double days = 0;
if (minDate == null || maxDate == null) {
    return days;
try {
    days = getIntervalHours(minDate, maxDate) / 24;
} catch (Exception e) {
    e.printStackTrace();
...
longgetIntervalDays(String sd, String ed)
get Interval Days
return ((java.sql.Date.valueOf(ed)).getTime() - (java.sql.Date
        .valueOf(sd)).getTime()) / (3600 * 24 * 1000);
doublegetIntervalHours(Date minDate, Date maxDate)
get Interval Hours
double days = 0.0;
if (minDate == null || maxDate == null) {
    return days;
try {
    days = getIntervalMinutes(minDate, maxDate) / 60;
} catch (Exception e) {
    e.printStackTrace();
...
doublegetIntervalMinutes(Date minDate, Date maxDate)
get Interval Minutes
double days = 0.0;
if (minDate == null || maxDate == null) {
    return days;
try {
    long interval = maxDate.getTime() - minDate.getTime();
    days = Double.valueOf(interval) / 1000 / 60;
} catch (Exception e) {
...
intgetIntervalYears(Date date1, Date date2)
get Interval Years
Calendar firstCal = Calendar.getInstance();
Calendar secondCal = Calendar.getInstance();
firstCal.setTime(date1);
secondCal.setTime(date2);
int year = firstCal.get(Calendar.YEAR)
        - secondCal.get(Calendar.YEAR);
int month = firstCal.get(Calendar.MONTH)
        - secondCal.get(Calendar.MONTH);
...
longhoursBetweenDate(Date date1, Date date2)
hours Between Date
long d = date1.getTime() - date2.getTime();
return d / 3600000;
longmillisecondsBetween(Date dt1, Date dt2)
milliseconds Between
if (dt1 == null || dt2 == null)
    return 0;
return Math.abs(dt1.getTime() - dt2.getTime());
longmillisecondsBetween(Date dt1, Date dt2)
milliseconds Between
if (dt1 == null || dt2 == null)
    return 0;
return Math.abs(dt1.getTime() - dt2.getTime());
longminuteBetweenDate(Date date1, Date date2)
minute Between Date
long d = date1.getTime() - date2.getTime();
return d / 60000;