I would make a conversion microflow to use in the importmapping from where ever you get your data from. You can use the ‘convert using’ option to translate your incoming string to whatever you want. That way the process is done once.
Incoming parameter for your microflow is a string, than a create variable action with the desired conversion and formatting and return the new string in the endpoint.