Here you can find the source of toCalendar(String str)
public static Calendar toCalendar(String str)
//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; } }