Use of system date

I write this post to ask how it is possible to handle the system date and save it as a variable to compare it to a fixed date string and use it as a condition for running a test case.

There are multiple ways of handling this. It really depends on what format you need the date to be in for the comparison. Can you give an example of what you mean by:


Manage the system date in the MM/DD/YYYY format, and compare with a date saved in a variable and if they are equal, execute an instruction.

Try this:

import java.text.SimpleDateFormat    

// get the date from the page
String savedDate = ...

// get today's date
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy")
String todaysDate = sdf.format(new Date())

// compare them
if(todaysDate.equals(savedDate)) {
    // do something...