Here you can find the source of toDate(String param)
public static Date toDate(String param)
//package com.java2s; /**/* ww w. j av a 2 s. c o m*/ * Tern Framework. * * @author fancimage * @Copyright 2010 qiao_xf@163.com Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 */ import java.util.Date; import java.text.SimpleDateFormat; import java.text.ParseException; public class Main { public static Date toDate(String param) { Date date = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { date = sdf.parse(param); } catch (ParseException ex) { } return date; } public static Date toDate(String param, String pattern) { if (param == null) return null; Date date = null; SimpleDateFormat sdf = new SimpleDateFormat(pattern); try { date = sdf.parse(param); } catch (ParseException ex) { } return date; } }