How to append zero(0) to user defined date? – User friendly Tech help

Scenario:- Creating date in user defined format like MM/DD/YYYY?
n
nSolution:- In one of our application automation, we came across a situation, where we 
nwanted to validate the date displayed on the AUT, for that we created the logical date to match with Actual Result .
n
nBut our validation was failing, reason being, for the single digit dates like 2nd month it was coming as ‘2’ but in our AUT it was getting displayed as ’02’.
n
nLogic:-To overcome this situation we created very agile and simple function.
nWe separated the required date into month,day and year part, concatenated ‘0’ to all the 
nparts and took the right most 2 digits, to create the required date format .We created date 
nin the format of ‘MM/DD/YYYY’,and the given function can be modified to return date 
nin any of the required patterns.
n
n
n
n

Was this article helpful?
YesNo

Similar Posts