Android examples for java.util:Calendar
Convert string in yyyy-MM-dd HH:mm:ss format To Calendar
import android.annotation.SuppressLint; import android.widget.TextView; import java.text.ParseException; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main{ public static Calendar strToCalendarLong(String strDate) { Calendar c = Calendar.getInstance(); try {//w w w. j a va 2 s .co m c.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") .parse(strDate)); } catch (ParseException e) { e.printStackTrace(); } return c; } }