Here you can find the source of formatDateToString(String strDate)
public static Date formatDateToString(String strDate)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date formatDateToString(String strDate) { Date date = null;/*from ww w .j a v a 2s . c o m*/ try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); date = sdf.parse(strDate); } catch (Exception e) { date = new Date(); } return date; } }