Here you can find the source of toDate(String date)
public static Date toDate(String date)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { static SimpleDateFormat YYYY_DD_MM = new SimpleDateFormat("yyyy-MM-dd"); static SimpleDateFormat YYYYDDMM = new SimpleDateFormat("yyyy/MM/dd"); public static Date toDate(String date) { try {// w w w .j a v a 2s . co m return YYYY_DD_MM.parse(date); } catch (ParseException e) { try { return YYYYDDMM.parse(date); } catch (ParseException e1) { return null; } } } }