How do i convert inputted DATE into a different format


Hello, I was wondering if someone can help. I need to verify a user inputted Date that’s in specific format, but then outputted in a different format. For example if user inputs the date as 12/09/2019 in a admin section, which is in the format of (‘MM/dd/yyyy’), but then it’s outputted as (‘Saturday, December 12, 2019’) , which is (‘EEEE, MMMM dd, yyyy’).

How do I convert the inputted date into a new format and verify that it is displayed in (‘EEEE, MMMM dd, yyyy’). Any example would be extremely helpful.



try this one

SimpleDateFormat sdf = new SimpleDateFormat("EEEE, MMMM dd, yyyy",Locale.ENGLISH);
Date parsedDate = null;
String sentDate = "Saturday, December 12, 2019";
parsedDate = sdf.parse(sentDate);
SimpleDateFormat print = new SimpleDateFormat("MM/dd/yyyy");
String sDate = print.format(parsedDate);




I actually needed it the other way around (MM/dd/yyyy) > (EEEE, MMMM dd, yyyy), but what you provided was more than enough for me to get to where I needed. Thanks appreciate the help. Added my results below in case anyone needs for reference.

import com.kms.katalon.core.logging.KeywordLogger as KeywordLogger

KeywordLogger log = new KeywordLogger()
SimpleDateFormat sdf = new SimpleDateFormat(“MM/dd/yyyy”);
Date parsedDate = null;
String sentDate = “12/09/2019”;
parsedDate = sdf.parse(sentDate);
SimpleDateFormat print = new SimpleDateFormat(“EEEE, MMMM dd, yyyy”,Locale.ENGLISH);
String sDate = print.format(parsedDate);

output: Monday, December 09, 2019



good to know that this helped you :sunglasses: