Need help handling different date formats between website and mobile app

Best practices, code snippets for common functionality, examples, and guidelines.
Otter_T
Posts: 16
Joined: Mon Aug 31, 2015 5:33 pm

Need help handling different date formats between website and mobile app

Post by Otter_T » Mon Jan 07, 2019 7:23 pm

I created a test with the following steps:

1) Using a desktop web browser, log into an account on a bank's internet banking site and enter a transaction.
2) Upon successfully entering the transaction, retrieve the transaction's effective date from a text field on the web page, and cast it as a variable.
3) Using the bank's mobile app, log into the same account and validate that the effective date of the transaction (the variable created in step 2) matches the date that was displayed on the internet banking site.

I created the test in late December, and it ran perfectly...until January 1, when I discovered that the mobile app is designed to trim leading zeroes from single-digit month/day values. So, if the web page shows 01/07/2019, the mobile app will show 1/7/2019.

I can't use any type of "current date", "current date plus 1 day", etc value for the variable. I have to use the effective date calculated by the website, because the effective date will vary based on holidays, weekends, and the time of day the transaction is entered.

Is there a way to trim the leading zeroes from the value being retrieved from the web page when it's cast as a variable?

Thank you for any suggestions or help you can provide.

User avatar
jarrettmk
Posts: 13
Joined: Wed Sep 19, 2018 6:10 pm

Re: Need help handling different date formats between website and mobile app

Post by jarrettmk » Mon Jan 07, 2019 9:06 pm

This would probably do the trick for you:
            var capturedVariable = "01/07/2019";
            var capturedVariableAsDateTime = Convert.ToDateTime(capturedVariable);
            var mobileCompatibleVariable = capturedVariableAsDateTime.ToString("M/d/yyyy");
Jarrett Karyshyn
Quality Assurance & Automation Engineer
USA - EST (UTC−05:00)/EDT (UTC−04:00)
Image

Otter_T
Posts: 16
Joined: Mon Aug 31, 2015 5:33 pm

Re: Need help handling different date formats between website and mobile app

Post by Otter_T » Mon Jan 07, 2019 10:47 pm

Thanks, Jarrett -- I'll give this a try!