Q: Convert plain string to time I have a String value which I need to convert into time and save it in the MySQL.[The column's datatype is time in the database table]
The examples of String values that I might encounter to convert into time object are:

String time = "5:32 PM";
String time = "12:00 AM";
String time = "11:43 PM";

I browsed for few examples which pulled the time from the Date object but couldn't find an apt example, such as in this case to convert it from a plain string. The main reason I need to convert it to time is to save it in the mysql.

A: You can convert it to  java.sql.Date  as :
String str = "5:32 PM";
DateFormat formatter = new SimpleDateFormat("hh:mm a");
java.util.Date date = (java.util.Date)formatter.parse(str);
java.sql.Date sqlDate = new java.sql.Date(date.getTime());

If you need java.sql.Time , then :
java.sql.Time time = new java.sql.Time(date.getTime());

And then use PreparedStatement#setTime().
