Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import android.widget.TextView; public class Main { public static Calendar viewText2Calendar(TextView tv) { final String date = tv != null ? tv.getText().toString() : ""; return string2Calendar(date); } public static Calendar string2Calendar(String date) { date = getDateNoWeek(date); final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date d; try { d = format.parse(date); } catch (ParseException e) { d = new Date(); } final Calendar mCalendar = (Calendar) Calendar.getInstance().clone(); mCalendar.setTime(d); return mCalendar; } public static String getDateNoWeek(String temp) { if (temp != null && temp.length() > 10) { return temp.substring(0, 10); } return temp; } public static String getDateNoWeek(TextView tv) { if (tv != null) { final String temp = tv.getText().toString(); return getDateNoWeek(temp); } return ""; } }