Here you can find the source of stringToCalendar(String stringTime)
public static Calendar stringToCalendar(String stringTime)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Calendar stringToCalendar(String stringTime, String pattern) { if ((stringTime != null) && (!(stringTime.isEmpty()))) { SimpleDateFormat format = new SimpleDateFormat(pattern); try { Date time = format.parse(stringTime); Calendar c = Calendar.getInstance(); c.setTime(time);//from w w w .java 2 s . c o m return c; } catch (ParseException e) { e.printStackTrace(); } } return null; } public static Calendar stringToCalendar(String stringTime) { return stringToCalendar(stringTime, "yyyyMMddHHmmss"); } }