Here you can find the source of getCurrentDateTimeObj(String dateTime, String format)
public static Date getCurrentDateTimeObj(String dateTime, String format) throws ParseException
//package com.java2s; //License from project: LGPL import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date getCurrentDateTimeObj(String dateTime) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.parse(dateTime); }// ww w .j av a2 s. com public static Date getCurrentDateTimeObj(String dateTime, String format) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.parse(dateTime); } }