Time conversion from string time to formatted time string

0
From a web service I get the time in a string. E.g.: 211400 as a value from the web service Now I want to format this time but the problem is that it doesn't format it to 21:14:00 but to 09:14:00 this is what I'm doing: formatTime(parseDateTime($Time, 'HHmmss')) Because the time is formatted to 09:14:00 instead of 21:14:00 I don't know if it is AM or PM. Using the capital "HH" I expected that it would have formatted to 21 instead of 09. Is that a correct expectation? I can build a cumbersome work-around, but this should just work right? Image
asked
2 answers
1

Mendix internally uses the same patterns as the SimpleDateFormat from Java: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html that documentation sometimes is more helpful.

I'm not really sure from your example what you are getting from the service and what mendix gets, but regardless if you want to use 9pm and show it later as 21hr you should also parse the pm indicator.

Simply parsing the hh:mm would assume it is AM not PM. So if you would like to parse the text "9:14 PM" you should use the pattern "hh:mm a" the "a" parses the AM/PM indicator and makes sure the time becomes 21hr.

Also make sure to use hh for a 1-12 hr notation. if you use HH (upper case) it will interpret it as a 24hr notation regardless and override/ignore the am/pm indicator.

answered
-1

In you should try formatDateTime(parseDateTime($Time, 'HHmmss'),'HH:mm:ss') You are missing the format when converting the number to a string.

answered