Here you can find the source of toDate(final String dateString, final String pattern)
public static final Date toDate(final String dateString, final String pattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final Date toDate(final String dateString, final String pattern) { final SimpleDateFormat sdf = new SimpleDateFormat(pattern); try {//from w w w.j a v a 2 s. co m return sdf.parse(dateString); } catch (final Exception e) { return null; } } }