Here you can find the source of toDate(String str)
public static Date toDate(String str) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date toDate(String str) throws ParseException { DateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS"); return format.parse(str); }/*from w ww. j a va 2 s.c o m*/ public static Date toDate(String str, String style) throws ParseException { DateFormat format = new SimpleDateFormat(style); return format.parse(str); } }