How i can to convert a string field ("HH:mm:ss") to time ("HH:mm:ss")?

0

Hello, please helpme.

In my database I have a string field with format HH:mm:ss and I need to change to a time field with format HH:mm:ss, that this field is displayed with the time format and that when exporting to a file excel keep the format.

I appreciate your help in advance.

r_suqui's picture
Joined: Nov 27 2014 - 11:37am
Last seen: 1 week 4 days ago

1 Answer:

0

You could just use the (old) SimpleDateFormat for that:

new SimpleDateFormat("hh:mm:ss").parse($F{YourTimeFieldAsString})

This should return a new java.util.Date with the parsed time but the 1.1.1970 (so the day/month/year are quite useless for your purpose).

Otherwise you could also use the "newer" Java LocalTime object... e.g. https://www.mkyong.com/java8/java-8-how-to-convert-string-to-localdate/

hth + regards

C-Box

C-Box's picture
1434
Joined: Jul 19 2006 - 5:58pm
Last seen: 21 hours 5 min ago
Feedback