Here you can find the source of stringToDate(String sDate)
public static Date stringToDate(String sDate) throws Exception
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date stringToDate(String sDate) throws Exception { SimpleDateFormat stringToDate; try {/*from w ww. j av a2s. c o m*/ stringToDate = new SimpleDateFormat("dd/MM/yyyy"); return stringToDate.parse(sDate); } catch (ParseException e) { stringToDate = new SimpleDateFormat("yyyy-MM-dd"); return stringToDate.parse(sDate); } } }