Java Parse Date Pattern YYYY parseStringToCalendar(String strDate)

Here you can find the source of parseStringToCalendar(String strDate)

Description

parse String To Calendar

License

Open Source License

Declaration

public static Calendar parseStringToCalendar(String strDate) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static Calendar parseStringToCalendar(String strDate) {
        java.util.Date date = parseStringToUtilDate(strDate);
        if (date == null) {
            return null;
        }//from ww w  .  ja  v  a 2  s .co  m
        Calendar ca = Calendar.getInstance();
        ca.setTime(date);
        return ca;
    }

    public static java.util.Date parseStringToUtilDate(String strDate) {

        java.util.Date date = null;
        try {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            date = df.parse(strDate);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return date;
    }
}

Related

  1. parseString2Long(String strDate)
  2. parseStringAsDate(String pattern, String value)
  3. parseStringDate(String dateAsString)
  4. parseStringDateToRmFormat(String date)
  5. parseStringForDate(String dateString)
  6. parseStringToDate(final String pDate, final String... pFormat)
  7. parseStringToDate(String date)
  8. parseStringToDate(String dateString)
  9. parseStringToDatePrettyPrint(Date date)