Java Calendar Parse toCalendar(String str)

Here you can find the source of toCalendar(String str)

Description

to Calendar

License

Apache License

Declaration

public static Calendar toCalendar(String str) 

Method Source Code

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

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

public class Main {
    public static Calendar toCalendar(String str) {
        Calendar cal = new GregorianCalendar();
        Date date = null;// w  w  w  . jav  a 2 s  .c  o m
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            date = sdf.parse(str);
            cal.setTime(date);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return cal;
    }
}

Related

  1. string2Calendar(String data)
  2. stringCalendar(Calendar cal)
  3. stringToCalendar(final String str, String format, boolean lenient)
  4. stringToCalendar(String fecha, String formato)
  5. toCalendar(Object value, String format)
  6. toGregorianCalendar(String value)
  7. toLocalCustomFormatCalendar( String calString, String format)