Here you can find the source of toDate(String dateStr)
public static Date toDate(String dateStr)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date toDate(String dateStr) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); try {/*from w ww .j a va 2s.co m*/ return sdf.parse(dateStr); } catch (Exception e) { return null; } } }