Here you can find the source of formatDate(String date)
public static Date formatDate(String date) throws Exception
//package com.java2s; //License from project: LGPL import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String DATE_FORMAT = "yyyy-MM-dd"; public static Date formatDate(String date) throws Exception { DateFormat myDateFormat = new SimpleDateFormat(DATE_FORMAT); return myDateFormat.parse(date); }//from ww w . j a v a2 s .co m }