Format a string matcher found

Asked

Viewed 37 times

1

I’m using matcher to pick up different time patterns but when writing the same I would like it to be written in the correct format, I tried to use Simpledateformat ("HH:mm:ss"), but it didn’t work.

For example: matcher found 17:4441 in the text. I need that somehow when I rewrite this string it returns 17:44:41;

1 answer

1


StringBuilder format = new StringBuilder();
   format.append(hora.substring(0, 2)).
   append(":").append(hora.substring(2, 4)).
   append(":").append(hora.substring(4, 6));
   System.out.println("Hora: " +format);

I managed this way to format the time matcher returned me

Browser other questions tagged

You are not signed in. Login or sign up in order to post.