Java - Convert String to Date

DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String ddMMyyyy = "20130128";
Date date = null;

date = (Date) formatter.parse(ddMMyyyy);



Or

DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dd_MM_yyyy = "2013-01-28";
Date date = null;

date = (Date) formatter.parse(dd_MM_yyyy);