Here you can find the source of string2Time(String time, DateFormat timeFormat)
public static Time string2Time(String time, DateFormat timeFormat)
//package com.java2s; import java.sql.Time; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); public static final DateFormat DEFAULT_TIME_FORMAT = new SimpleDateFormat("HH:mm:ss"); public static Time string2Time(String time, DateFormat timeFormat) { if (time == null) return null; return new Time(string2Date(time, timeFormat).getTime()); }/*from w w w . j a va 2 s .co m*/ public static Time string2Time(String time, String timeFormat) { if (time == null) return null; return new Time(string2Date(time, timeFormat).getTime()); } public static Time string2Time(String time) { return string2Time(time, DEFAULT_TIME_FORMAT); } public synchronized static Date string2Date(String date, DateFormat dateFormat) { if (date == null) return null; try { return dateFormat.parse(date); } catch (ParseException e) { throw new IllegalArgumentException(e); } } public static Date string2Date(String date, String dateFormat) { return string2Date(date, new SimpleDateFormat(dateFormat)); } public static Date string2Date(String date) { return string2Date(date, DEFAULT_DATE_FORMAT); } }