Android Calendar Parse convertStringToCalendar(String stringDate)

Here you can find the source of convertStringToCalendar(String stringDate)

Description

convert String To Calendar

Declaration

public static Calendar convertStringToCalendar(String stringDate) 

Method Source Code

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

public class Main {
    private static String TAG = "DateTimeHelper";
    private static String invalidDateFormat = "Invalid date format";

    public static Calendar convertStringToCalendar(String stringDate) {
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy");
        Date date = null;// w w w  .  j a  v  a2  s. c  o m

        try {
            date = (Date) formatter.parse(stringDate);
        } catch (java.text.ParseException e) {
            Log.w(TAG, invalidDateFormat);
        }

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar;
    }
}

Related

  1. pars2Calender(String s)
  2. stringToCalendar(String date)
  3. getCalendarFromString(String time)
  4. getSelectCalendar(String dateStr, String pattern)
  5. getDesignatedCalendar(String unformattedTime)