Android examples for java.util:Date Convert
convert String To Calendar
import android.content.Context; import android.provider.Settings; import android.telephony.PhoneNumberUtils; import java.io.File; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Random; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ /**//from ww w .j a v a 2 s. c om * Convert string to calendar * * @param time * @return */ public static Calendar convertStringToCalendar(String time, String format) { Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateformat = new SimpleDateFormat(format); Date date = null; try { date = dateformat.parse(time); calendar.setTime(date); return calendar; } catch (ParseException e) { return calendar; } } }