Here you can find the source of getTimeDate(String time)
public static Date getTimeDate(String time)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); private static SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static Date getTimeDate(String time) { // format "yyyy-MM-dd HH:mm:00" String string = sdf.format(getCurrentDateTime()); string += " " + time; Date date = null;/*from w w w .j ava2 s. c om*/ try { date = sdf2.parse(string); } catch (ParseException e) { e.printStackTrace(); } return date; } public static String format(Date date) { return sdf2.format(date); } /** * Gets the current date time. * * @return the current date time */ public static Date getCurrentDateTime() { Calendar calendar = Calendar.getInstance(); return calendar.getTime(); } }