Here you can find the source of string2calendar(String s, String formatString)
public static Calendar string2calendar(String s, String formatString)
//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 string2calendar(String s, String formatString) { Calendar calendar = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(formatString); Date d = null;//from w w w. ja va 2 s . c o m try { d = sdf.parse(s); } catch (ParseException ignore) { } calendar.setTime(d); // http://stackoverflow.com/questions/5301226/convert-string-to-calendar-object-in-java return calendar; /* NOTE: ????????????????????????????????????????????? Date date = null; Calendar calendar = Calendar.getInstance(); try { date = DateFormat.getDateInstance().parse(s); calendar.setTime(date); // http://sauke-11.jugem.jp/?eid=63 // http://d.hatena.ne.jp/chiheisen/20091123/1258986655 } catch (ParseException ignore) { } return calendar; */ } }