I have a date picker option on my website where I have to pick up a date for after 2 weeks from current date, how do I do that using java programming language?
1 Answer
The below code should give you two weeks from the current date
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Calendar c = Calendar.getInstance();
c.setTime(new Date()); // Use today date
c.add(Calendar.DATE, 14); // Adding 14 days which is two weeks from the current date
String output = sdf.format(c.getTime());
Selecting this date from the date picker will require knowing what type of date picker is used in your website.
Check out the below link for more on how to select if using selenium https://stackoverflow.com/questions/21398575/select-a-date-from-date-picker-using-selenium-webdriver