Here you can find the source of convertToDate(String value)
public static Date convertToDate(String value)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { static SimpleDateFormat FMT = new SimpleDateFormat("dd-MMM-yyyy"); static SimpleDateFormat FMT2 = new SimpleDateFormat("yyyy-MM-dd"); public static Date convertToDate(String value) { if (value == null) return null; value = value.trim();//w w w . ja va 2 s . c om if (value.length() == 0) return null; Date date = null; try { date = FMT.parse(value); } catch (ParseException pe1) { try { date = FMT2.parse(value); } catch (ParseException pe2) { throw new RuntimeException("unable to parse date [" + value + "]"); } } return date; } }