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

DatetoDateTime(Date date, Date time)
to Date Time
if (date == null)
    return null;
if (time == null)
    return date;
Calendar d = new GregorianCalendar();
d.setTime(date);
Calendar t = new GregorianCalendar();
t.setTime(time);
...
DateoffsetDate(Date date, int field, int offset)
offset Date
Calendar calendar = convert(date);
calendar.add(field, offset);
return calendar.getTime();
StringchangeDate(String argDate)
change Date
if (argDate == null || argDate.trim().equals("")) {
    return "";
String result = "";
if (argDate.length() == 10 && argDate.indexOf("/") > 0) {
    return argDate;
String[] str = argDate.split("[.]");
...
DatefirstTimeOfDate(Date date)
first Time Of Date
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(date.getTime());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
Date dateBegin = new Date();
dateBegin.setTime(calendar.getTimeInMillis());
return dateBegin;
DateresetTime(Date date)
reset Time
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
DateremoveTime(Date date)
Remove the time of a date value
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(date);
gc.set(Calendar.HOUR_OF_DAY, 0);
gc.set(Calendar.MINUTE, 0);
gc.set(Calendar.SECOND, 0);
gc.set(Calendar.MILLISECOND, 0);
return gc.getTime();