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

intgetMonth()
get Month
return cal().get(Calendar.MONTH);
intgetMonth(Calendar c)
get Month
if (c != null) {
    return c.get(Calendar.MONTH);
} else {
    return Calendar.getInstance().get(Calendar.MONTH);
intgetSecond(Calendar c)
get Second
if (c != null) {
    return c.get(Calendar.SECOND);
} else {
    return Calendar.getInstance().get(Calendar.SECOND);
longgetTimeByStr(String str)
get Time By Str
SimpleDateFormat sdf = new SimpleDateFormat(PARSE_DATE_FORMAT);
Date date;
try {
    date = sdf.parse(str);
    return date.getTime();
} catch (ParseException e) {
    e.printStackTrace();
    return System.currentTimeMillis();
...
longgetTimeMillis()
get Time Millis
return System.currentTimeMillis();
StringgetWeek(final Calendar calendar)
get Week
final int weekOfYear = calendar.get(Calendar.WEEK_OF_YEAR);
return String.valueOf(weekOfYear);
StringgetWeek(final Long date)
get Week
final Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(date);
return getWeek(calendar);
intgetYear()
get Year
return cal().get(Calendar.YEAR);
intgetYear(Calendar c)
get Year
if (c != null) {
    return c.get(Calendar.YEAR);
} else {
    return Calendar.getInstance().get(Calendar.YEAR);
StringextractDateFromCalendarTime(Calendar time)
extract Date From Calendar Time
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MM-yyyy");
return dateFormatter.format(time.getTime());