Here you can find the source of stringToCalendar(String date)
public static Calendar stringToCalendar(String date)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public final static String SQL_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static Calendar stringToCalendar(String date) { Date myNewDate = null;/*from w w w . ja v a 2s . c o m*/ Calendar calendar = Calendar.getInstance(); if (date == null || date.length() == 0) return null; SimpleDateFormat dateFormat = new SimpleDateFormat(SQL_DATE_FORMAT); try { myNewDate = dateFormat.parse(date); calendar.setTime(myNewDate); } catch (ParseException e) { e.printStackTrace(); } return calendar; } }