My application displays dates in different formats based on user settings. I want to test that it displays correct date format. I have the displayed date as a string (2014/12/31). I do not want to verify the actual date, but just the format.
Ex: When user selects yyyy/dd/MM format, it should display it in that format.
1.) try and parse the String to the required Date using something like
SimpleDateFormat
check like above.
2.) Other approach can be to use regex, but then you have to inbuilt few supported data format regex in your application, and pick accordingly. Play around the
{2}, {2}, {4}
values inside curly braces to prepare regex.more info here