Here you can find the source of getStringToDateTime(String dateStr, String formatStr)
public static Date getStringToDateTime(String dateStr, String formatStr) throws Exception
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date getStringToDateTime(String dateStr, String formatStr) throws Exception { SimpleDateFormat format = new SimpleDateFormat(formatStr); Date date = null;/*from w w w . ja va 2s .c o m*/ date = format.parse(dateStr); return date; } }