Here you can find the source of createSqlDate(String dateStr)
public static java.sql.Date createSqlDate(String dateStr)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static SimpleDateFormat df[] = { new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"), new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"), new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"), new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"), new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss"), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), new SimpleDateFormat("MM/dd/yyyy'T'HH:mm:ss.SSS'Z'"), new SimpleDateFormat("MM/dd/yyyy'T'HH:mm:ss.SSSZ"), new SimpleDateFormat("MM/dd/yyyy'T'HH:mm:ss.SSS"), new SimpleDateFormat("MM/dd/yyyy'T'HH:mm:ssZ"), new SimpleDateFormat("MM/dd/yyyy'T'HH:mm:ss"), new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"), new SimpleDateFormat("MM/dd/yyyy HH:mm"), new SimpleDateFormat("MM/dd/yyyy"), new SimpleDateFormat("yyyy:MM:dd HH:mm:ss"), new SimpleDateFormat("yyyyMMdd") }; public static java.sql.Date createSqlDate(String dateStr) { Date date = createDate(dateStr); if (date != null) { return new java.sql.Date(date.getTime()); }// w ww. j a v a 2 s . c o m return null; } public static Date createDate(String dateStr) { Date returnDate; for (int i = 0; i < df.length; i++) { try { returnDate = df[i].parse(dateStr); return returnDate; } catch (Exception ex) { // Try next one... } } return null; } }