Convert Date Time and Decimal to user specific format

Jan 20 2021 11:26 AM
I am writing a function to convert Decimal/Datetime to the format specified by user.
For example:
If my input string is 1234.1254 and format string is "000.00" then the output should be 1234.13.
Same goes for Datetime, if input is DateTime.Now and format string is "dd/MM/yyyy" then the date should be returned in the given format.
I am not sure how can I achieve this, any suggestions on how can I proceed here?

Answers (3)