Here you can find the source of getStringToDate(String date, String format)
public static Date getStringToDate(String date, String format)
//package com.java2s; /**//from w ww . jav a 2 s .c o m * Copyright (c)2010-2011 Enterprise Website Content Management System(EWCMS), All rights reserved. * EWCMS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * http://www.ewcms.com */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; public static Date getStringToDate(String date) { return getStringToDate(date, DEFAULT_DATE_FORMAT); } public static Date getStringToDate(String date, String format) { SimpleDateFormat simple = new SimpleDateFormat(format); try { return simple.parse(date); } catch (ParseException e) { return null; } } }