Android Utililty Methods Date Offset

List of utility methods to do Date Offset

Description

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

Method

StringgetTimeWithFormat(int year, int month, int day, int hour, int minute)
get Time With Format
SimpleDateFormat timeFormat = new SimpleDateFormat("h:mma");
return timeFormat.format(new GregorianCalendar(year, (month - 1),
        day, hour, minute).getTime());
DatethirdDayWithHour()
third Day With Hour
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_MONTH, 2);
int hour = cal.get(Calendar.HOUR_OF_DAY) + 1;
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
...
CalendargetDateFormOffset(int months, int days, int hours, int minutes)
get Date Form Offset
Calendar selectedDate = getCurrentDate();
selectedDate.add(Calendar.DAY_OF_MONTH, days);
selectedDate.add(Calendar.MONTH, months);
selectedDate.add(Calendar.HOUR_OF_DAY, hours);
selectedDate.add(Calendar.MINUTE, minutes);
return selectedDate;
StringgetDateAndTimeWithShortFormat(boolean withYear, int year, int month, int day, int hour, int minute)
get Date And Time With Short Format
SimpleDateFormat dateTimeFormat;
if (withYear) {
    dateTimeFormat = new SimpleDateFormat("EEE, MMM d, yyyy h:mma");
} else {
    dateTimeFormat = new SimpleDateFormat("EEE, MMM d, h:mma");
return dateTimeFormat.format(new GregorianCalendar(year,
        (month - 1), day, hour, minute).getTime());
...
longconvertToUnixTimeOneDayLater(Date date)
Converts into a "unix time", which means convert into the number of seconds (NOT milliseconds) from the Epoch fit for the Facebook Query Language.
long time = date.getTime() / 1000L;
time += SECONDS_IN_DAY;
return time;