Android Utililty Methods Calendar Parse

List of utility methods to do Calendar Parse

Description

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

Method

Calendarpars2Calender(String s)
pars Calender
Timestamp ts = Timestamp.valueOf(s);
return Timestamp2Calendar(ts);
CalendarstringToCalendar(String date)
string To Calendar
Date myNewDate = null;
Calendar calendar = Calendar.getInstance();
if (date == null || date.length() == 0)
    return null;
SimpleDateFormat dateFormat = new SimpleDateFormat(SQL_DATE_FORMAT);
try {
    myNewDate = dateFormat.parse(date);
    calendar.setTime(myNewDate);
...
CalendarconvertStringToCalendar(String stringDate)
convert String To Calendar
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy");
Date date = null;
try {
    date = (Date) formatter.parse(stringDate);
} catch (java.text.ParseException e) {
    Log.w(TAG, invalidDateFormat);
Calendar calendar = Calendar.getInstance();
...
CalendargetCalendarFromString(String time)
get Calendar From String
String[] timeParts = time.split(":");
int hour = Integer.parseInt(timeParts[0]);
int minute = Integer.parseInt(timeParts[1]);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
return calendar;
CalendargetSelectCalendar(String dateStr, String pattern)
get Select Calendar
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
Date date = formatter.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar;
CalendargetDesignatedCalendar(String unformattedTime)
get Designated Calendar
unformattedTime = unformattedTime.replaceAll("(\\+[0-9+:]+)|Z", "");
String[] updateTimes = unformattedTime.substring(0,
        unformattedTime.length()).split("T");
String[] date = updateTimes[0].split("-");
String[] times = updateTimes[1].split(":");
int year = Integer.parseInt(date[0]);
int month = Integer.parseInt(date[1]);
int day = Integer.parseInt(date[2]);
...