I need to pick random date from the calendar and also I want to pick current date from the calender

I would set up a variable equal to now to pick the current date and then pass that variable into the field. Not knowing the application you are working with or how the date entry works makes it hard to come up with a solution though.

Here is an example of getting current calendar time:

this is what I have done to always pick date in the future by 14 days:

DateFormat dateFormat = new SimpleDateFormat(‘MM-dd-yyyy’)

Date currentDate = new Date()

Calendar c = Calendar.getInstance()


c.add(Calendar.DATE, 14)

Date currentDatePlus14 = c.getTime()

I put that right into the test case. You could pick this appart and come up with just the current date by not using the add. Hopefully this is helpful

1 Like