Android Calendar String Parse getCalendarFromString(final String date)

Here you can find the source of getCalendarFromString(final String date)

Description

get Calendar From String

Declaration

public static Calendar getCalendarFromString(final String date) 

Method Source Code

//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.util.Log;

public class Main {
    public static Calendar getCalendarFromString(final String date) {
        final SimpleDateFormat inputFormat = new SimpleDateFormat(
                "E, MMMM dd, yyyy");
        Date parsedDate = new Date();
        try {/*from  ww  w. ja v  a 2s  . com*/
            parsedDate = inputFormat.parse(date.trim());
        } catch (final ParseException e) {
            Log.e("DATE_PARSER",
                    "Error: Impossible to parse input string to calendar.",
                    e);
            throw new RuntimeException(e);
        }

        final Calendar currentDate = Calendar.getInstance();
        currentDate.setTime(parsedDate);

        return currentDate;
    }
}

Related

  1. parseCalendar(int year, int month, double day, TimeZone zone)
  2. parseCalendar(int year, int month, int day, int hour, int minute, int second, int millisecond, TimeZone zone)
  3. parseDA(Calendar c, String s, int off, int len)
  4. parseTM(Calendar c, String s, int off, int len)
  5. getAsCalendar(String dateString)
  6. stringToCalendar(String date)