Android examples for java.util:Date Format
from Hyphenated Date String yyyy-MM-dd
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { public static Calendar fromHyphenatedDateString(String hyphenatedDateString) { Calendar calendar = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); try {/*from www .j a v a2s . co m*/ Date date = sdf.parse(hyphenatedDateString); calendar.setTime(date); } catch (ParseException e) { e.printStackTrace(); } return calendar; } }