Here you can find the source of getCalendarFromDateString(String dateString, String format, Locale locale)
public static Calendar getCalendarFromDateString(String dateString, String format, Locale locale)
import android.annotation.SuppressLint; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Locale; public class Main{ public static Calendar getCalendarFromDateString(String dateString, String format, Locale locale) { SimpleDateFormat formatter = new SimpleDateFormat(format, locale); Calendar cal = Calendar.getInstance(); try {// w w w . j av a 2s.c o m cal.setTime(formatter.parse(dateString)); } catch (ParseException e) { DebugLog.e("ParseException"); return null; } return cal; } }