Here you can find the source of stringToDate(String dateString, String dateFormat)
public static Date stringToDate(String dateString, String dateFormat)
//package com.java2s; /*/*from ww w. j a va 2s. c om*/ * Title: TRS ?????? * Copyright: Copyright (c) 2004-2005, TRS?????????????. All rights reserved. * License: see the license file. * Company: TRS?????????????(www.trs.com.cn) * * Created on 2005-5-11 */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date stringToDate(String dateString, String dateFormat) { if ("".equals(dateString) || dateString == null) { return null; } try { return new SimpleDateFormat(dateFormat).parse(dateString); } catch (Exception e) { return null; } } }