Android Utililty Methods Calendar Get

List of utility methods to do Calendar Get

Description

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

Method

intgetDate(Calendar c)
get Date
if (c != null) {
    return c.get(Calendar.DATE);
} else {
    return Calendar.getInstance().get(Calendar.DATE);
StringgetDateAsDirName()
get Date As Dir Name "yyyy-MM-dd"
Calendar cal = Calendar.getInstance();
java.text.SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String cdate = sdf.format(cal.getTime());
return cdate;
StringgetDateAsF()
get Date As F "yyyyMMddHHmmss"
Calendar cal = Calendar.getInstance();
java.text.SimpleDateFormat sdf = new SimpleDateFormat(
        "yyyyMMddHHmmss");
String cdate = sdf.format(cal.getTime());
return cdate;
StringgetDateAss()
get Date As "MM-dd-HH-mm"
Calendar cal = Calendar.getInstance();
java.text.SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-HH-mm");
String cdate = sdf.format(cal.getTime());
return cdate;
StringgetDateMin()
get Date Min, "yyyy-MM-dd HH:mm"
Calendar cal = Calendar.getInstance();
java.text.SimpleDateFormat sdf = new SimpleDateFormat(
        "yyyy-MM-dd HH:mm");
String cdate = sdf.format(cal.getTime());
return cdate;
intgetDay()
get Day
return cal().get(Calendar.DAY_OF_WEEK);
intgetDay(Calendar c)
get Day
if (c != null) {
    return c.get(Calendar.DAY_OF_WEEK);
} else {
    return Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
TimestampgetFirstOfWeek(Calendar cal, int week)
get First Of Week
if (cal == null) {
    cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
...
longgetFragmentInDays(Calendar calendar, int fragment)

Returns the number of days within the fragment.

return getFragment(calendar, fragment, Calendar.DAY_OF_YEAR);
longgetFragmentInHours(Calendar calendar, int fragment)

Returns the number of hours within the fragment.

return getFragment(calendar, fragment, Calendar.HOUR_OF_DAY);