Here you can find the source of stringToDate(String vStr, String vPatten)
public static Date stringToDate(String vStr, String vPatten)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static Date stringToDate(String vStr, String vPatten, Locale vLocale) { if (vStr == null || vPatten == null || vLocale == null) { throw new IllegalArgumentException("The vStr and the vPatten and the vLocale must not be null"); }/*from w w w. j a v a2 s . c o m*/ if (vStr.equals("")) return null; try { SimpleDateFormat df = new SimpleDateFormat(vPatten, vLocale); return df.parse(vStr); } catch (Exception ex) { return null; } } public static Date stringToDate(String vStr, String vPatten) { if (vStr == null || vPatten == null) { throw new IllegalArgumentException("The vStr and the vPatten must not be null"); } if (vStr.equals("")) return null; try { SimpleDateFormat df = new SimpleDateFormat(vPatten); return df.parse(vStr); } catch (Exception ex) { return null; } } }