What I want to do is so you have a list of random dates, it will never be the same so it has to be a universal formula, but you get any date, any date of the year and then e
For new Java 8 Time API, you can use below code. You need to change DayOfWeek.THURSDAY
etc in the below code.
LocalDate date1=LocalDate.now();
// This will give you int value of Day(for eg. Friday) and the date you want to check for
int duration=DayOfWeek.WEDNESDAY.getValue()-date1.getDayOfWeek().getValue();
System.out.println("duration "+duration);
if(date1.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)) {
System.out.println("Wednesday");
} else {
date1=date1.plusDays(7).minusDays(7- duration);
}
// it will first give next day of week then minus the duration from 7.
System.out.println("new date1 "+date1);