Android Utililty Methods Date Set

List of utility methods to do Date Set

Description

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

Method

DatesetMinute(Date date, int minutes)
set Minute
return setTime(date, -1, minutes, -1, -1);
DatesetMinutes(Date date, int amount)
Sets the minute field to a date returning a new object.
return set(date, Calendar.MINUTE, amount);
DatesetMonths(Date date, int amount)
Sets the months field to a date returning a new object.
return set(date, Calendar.MONTH, amount);
DatesetSeconds(Date date, int amount)
Sets the seconds field to a date returning a new object.
return set(date, Calendar.SECOND, amount);
DatesetTime(Date date, int hour, int minute, int second, int millisecond)
set Time
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.HOUR_OF_DAY,
        hour >= 0 ? hour : c.get(Calendar.HOUR_OF_DAY));
c.set(Calendar.MINUTE,
        minute >= 0 ? minute : c.get(Calendar.MINUTE));
c.set(Calendar.SECOND,
        second >= 0 ? second : c.get(Calendar.SECOND));
...
DatesetTime(Date date, int hours, int minutes)
set Time
return setTime(date, hours, minutes, -1, -1);
DatesetTime(Date date, int hours, int minutes, int seconds)
set Time
return setTime(date, hours, minutes, seconds, -1);
DatesetYears(Date date, int amount)
Sets the years field to a date returning a new object.
return set(date, Calendar.YEAR, amount);
StringshortDate(Date date)
short Date
return format(date, "MM-dd");
Stringtime(Date date)
time
return format(date, "HH:mm");