Aakash Patel Aakash Patel - 3 months ago 28
Java Question

How do i convert "HH:MM" format string to TimeStamp in java?

I have a string **09:28.**But i want to convert this string in TimeStamp object.
How can i do that?
Below is my coding.

Object d = getMappedObjectValue(reportBeamDataMap, ReportBeamConstant.DAT_STOPDATE);
Date stopDate1 = (Date)d;`
SimpleDateFormat printFormat = new SimpleDateFormat("hh:mm");`
String timeString = printFormat.format(stopDate1);`

Now I want above String in
TimeStamp(Only HH:MM)
. How to do that?


Please Use parse method to get Date Object and then construct Timestamp object.

 try {
    Timestamp timestamp = new Timestamp(printFormat.parse(timeString).getTime());
    } catch (ParseException e) {