Java Calendar Parse str2Calendar(String pString)

Here you can find the source of str2Calendar(String pString)

Description

Converts a string to a Calendar object

License

Open Source License

Parameter

Parameter Description
pString A string representing a Calendar

Return

Calendar

Declaration

public static Calendar str2Calendar(String pString) 

Method Source Code

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

public class Main {
    /**/*from  w  ww . j  ava  2 s  .c o  m*/
     * <p>Converts a string to a Calendar object</p>
     *
     * @param pString A string representing a Calendar
     * @return Calendar
     */
    public static Calendar str2Calendar(String pString) {
        Calendar cal = null;
        if (pString != null) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
                Date d = sdf.parse(pString);
                cal = Calendar.getInstance();
                cal.setTime(d);
            } catch (ParseException e) {
            }
        }
        return cal;
    }
}

Related

  1. convertStringToCalendar(String time)
  2. getCalendar(Object source)
  3. getCalendarObject(String value, boolean hasMills)
  4. str2Calendar(String str, String format)
  5. string2Calendar(String data)
  6. stringCalendar(Calendar cal)
  7. stringToCalendar(final String str, String format, boolean lenient)