Java Calendar Parse convertStringToCalendar(String time)

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

Description

convert String To Calendar

License

Apache License

Declaration

public static Calendar convertStringToCalendar(String time) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Calendar convertStringToCalendar(String time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendarDate = Calendar.getInstance();
        Date dateObj = null;/*from   w ww.j  a  v  a2  s .c o m*/
        try {
            dateObj = sdf.parse(time);

            calendarDate.setTime(dateObj);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return calendarDate;
    }
}

Related

  1. getCalendar(Object source)
  2. getCalendarObject(String value, boolean hasMills)
  3. str2Calendar(String pString)
  4. str2Calendar(String str, String format)