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

intminutesBetween(Date dt1, Date dt2)
minutes Between
long msDiff = millisecondsBetween(dt1, dt2);
if (msDiff == 0)
    return 0;
return (int) (msDiff / 60000);
intminutesBetween(Date dt1, Date dt2)
minutes Between
long msDiff = millisecondsBetween(dt1, dt2);
if (msDiff == 0)
    return 0;
return (int) (msDiff / 60000);
DateoffsetMinute(Date date, int offset)
offset Minute
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.MINUTE,
        (calendar.get(Calendar.MINUTE) + offset));
return calendar.getTime();
DateoffsetSecond(Date date, int offset)
offset Second
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.SECOND,
        (calendar.get(Calendar.SECOND) + offset));
return calendar.getTime();
longsecondBetweenDate(Date date1, Date date2)
second Between Date
long d = date1.getTime() - date2.getTime();
return d / 1000;
intsecondDiff(Date date1, Date date2)
second Diff
long diff = date1.getTime() - date2.getTime();
long day = diff / ND;
long min = diff % ND % NH / NM + day * 24 * 60;
return (int) min;
intsecondDiff(String startTime, String endTime)
second Diff
SimpleDateFormat sd = new SimpleDateFormat(YMD_DASH_WITH_TIME);
long diff = 0;
long min = 0;
try {
    diff = sd.parse(endTime).getTime()
            - sd.parse(startTime).getTime();
    long day = diff / ND;
    min = diff % ND % NH / NM + day * 24 * 60;
...
intsecondsBetween(Date dt1, Date dt2)
seconds Between
long msDiff = millisecondsBetween(dt1, dt2);
if (msDiff == 0) {
    return 0;
return (int) (msDiff / 1000);
intgetDateOffset()
get Date Offset
int day = getDay();
int hour = getHour();
int minute = getMinute();
int offset = 0;
if (day == Calendar.SATURDAY) {
    offset++;
} else if (day == Calendar.FRIDAY
        && (hour > 15 || hour == 15 && minute >= 15)) {
...
longinterval(Date date)
interval
return (Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00"))
        .getTimeInMillis() - date.getTime()) / 1000;