Android Calendar Parse stringToCalendar(String date)

Here you can find the source of stringToCalendar(String date)

Description

string To Calendar

Declaration

public static Calendar stringToCalendar(String date) 

Method Source Code

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

public class Main {
    public final static String SQL_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static Calendar stringToCalendar(String date) {
        Date myNewDate = null;/*from   w w w . ja v a 2s .  c o m*/
        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);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return calendar;
    }
}

Related

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