2

I am dealing with time strings such as "1030" or "0230"

I am trying:

var time = "1030";
DateFormat.jm().format(DateFormat("hhmm").parse(time));

However that throws the following error:

Unhandled Exception: FormatException: Trying to read mm from 1030 at position 4

What am I doing wrong?

Edit: Nvm, I guess I have to substring the time into "hour:min" and use "hh:mm", then it works. So, convert the time "1030" to "10:30", and then use "hh:mm"..

user1354934
  • 8,139
  • 15
  • 50
  • 80

1 Answers1

4

use

HH:mm

var time = "10:30";
DateFormat.jm().format(DateFormat("HH:mm").parse(time));
  • Thanks, this is what I end up doing, however I have to substring. I am using google places api fwiw, and place in the colon in between between – user1354934 Mar 24 '22 at 20:40