Here you can find the source of string2Date(String s, String s1)
public static Date string2Date(String s, String s1)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date string2Date(String s, String s1) { Date date = new Date(); try {//w ww . j av a 2 s. co m String s2 = stringNull(s1); SimpleDateFormat simpledateformat = new SimpleDateFormat(s2); String s3 = stringNull(s); date = simpledateformat.parse(s3); } catch (Exception exception) { } return date; } public static String stringNull(String s) { if (s != null) { s = s.trim(); if (s.equals("") || s.equalsIgnoreCase("null")) s = ""; } return s; } }