Here you can find the source of string2Calendar(String data)
public static Calendar string2Calendar(String data)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static Calendar string2Calendar(String data) { SimpleDateFormat sdf1 = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); try {/*from www . j a v a 2 s . c o m*/ if (data.contains("/")) cal.setTime(sdf1.parse(data)); else cal.setTime(sdf2.parse(data)); } catch (ParseException e) { e.printStackTrace(); } return cal; } }