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

StringextractTimeFromCalendarTime(Calendar time)
extract Time From Calendar Time
SimpleDateFormat timeFormatter = new SimpleDateFormat("hh:mm a");
return timeFormatter.format(time.getTime());
CalendargetCurrentCalendar()
get Current Calendar
Calendar currentCal = new GregorianCalendar(Locale.JAPAN);
return currentCal;
StringgetCurrentDateByOffset(String format, int calendarField, int offset)
get Current Date By Offset
String mDateTime = null;
try {
    SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(
            format);
    Calendar c = new GregorianCalendar();
    c.add(calendarField, offset);
    mDateTime = mSimpleDateFormat.format(c.getTime());
} catch (Exception e) {
...
CalendargetCalenderFromDateString(String dateString)
parse Date string like: "Sat Sep 21 23:39:40 +0800 2013" to java.util.Date object
Calendar cal = Calendar.getInstance();
try {
    cal.setTime(weiboCreateDateFormat.parse(dateString));
} catch (ParseException e) {
    cal.setTime(new Date(0));
return cal;