Here you can find the source of getDateFromString(String strDate, String strTime)
public static Date getDateFromString(String strDate, String strTime)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static Date getDateFromString(String strDate, String strTime) { Calendar cal = Calendar.getInstance(); String[] arrDate = strDate.split("-"); String[] arrTime = strTime.split("[:-]"); cal.set(Integer.parseInt(arrDate[0]), Integer.parseInt(arrDate[1]) - 1, Integer.parseInt(arrDate[2]), Integer.parseInt(arrTime[0]), Integer.parseInt(arrTime[1]), Integer.parseInt(arrTime[1])); return cal.getTime(); }/* w w w . j a v a 2s .c o m*/ public static Date getDateFromString(String dateString) { Date ret = null; String[] tmp = dateString.split("-"); if (tmp.length == 3) { Calendar c = Calendar.getInstance(); c.set(Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1]) - 1, Integer.parseInt(tmp[2]), 0, 0, 0); ret = c.getTime(); } return ret; } }