Android Utililty Methods Date Get

List of utility methods to do Date Get

Description

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

Method

DategetDate(String sDate, String dateFormat)
get Date
SimpleDateFormat fmt = new SimpleDateFormat(dateFormat);
ParsePosition pos = new ParsePosition(0);
return fmt.parse(sDate, pos);
DategetDate(int year, int month, int date, int hourOfDay, int minute, int second)
get Date
Calendar cal = new GregorianCalendar();
cal.set(year, month, date, hourOfDay, minute, second);
return cal.getTime();
DategetDateFromString(String dateStr, String pattern)
get Date From String
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
Date resDate = null;
try {
    resDate = sdf.parse(dateStr);
} catch (Exception e) {
    e.printStackTrace();
return resDate;
...
DategetDateObj()
get Date Obj
Calendar c = new GregorianCalendar();
return c.getTime();
DategetDateObj(String argsDate, String split)
get Date Obj
String[] temp = argsDate.split(split);
int year = Integer.valueOf(temp[0]);
int month = Integer.valueOf(temp[1]);
int day = Integer.valueOf(temp[2]);
return getDateObj(year, month, day);
DategetDateObj(int year, int month, int day)
get Date Obj
Calendar c = new GregorianCalendar();
c.set(year, month - 1, day);
return c.getTime();
StringgetDateOffset(String date, int offset)
get Date Offset
Date tempDate = null;
if (date.indexOf("/") > 0)
    tempDate = getDateObj(date, "[/]");
if (date.indexOf("-") > 0)
    tempDate = getDateObj(date, "[-]");
tempDate = getDateAdd(tempDate, offset);
return getFormatDateTime(tempDate, "yyyy/MM/dd");
StringgetDateTomorrow(String date)
get Date Tomorrow
Date tempDate = null;
if (date.indexOf("/") > 0)
    tempDate = getDateObj(date, "[/]");
if (date.indexOf("-") > 0)
    tempDate = getDateObj(date, "[-]");
tempDate = getDateAdd(tempDate, 1);
return getFormatDateTime(tempDate, "yyyy/MM/dd");
intgetDayOfWeek(Date date)
get Day Of Week
Calendar cal = new GregorianCalendar();
cal.setTime(date);
return cal.get(Calendar.DAY_OF_WEEK);
intgetDayOfWeek(String date)
get Day Of Week
String[] temp = null;
if (date.indexOf("/") > 0) {
    temp = date.split("/");
if (date.indexOf("-") > 0) {
    temp = date.split("-");
return getDayOfWeek(temp[0], temp[1], temp[2]);
...