I know there have been many questions asked on SO re converting java.util.Date
to java.util.Calendar
, but I have spent a good few hours trying to solve my issue, looking at the APIs and numerous SO answers - hence my question.
I'm in the process of modifying an existing JSP page that utilises an API that has not been updated to work with the java.time API. And which requires the variable being passed to be in the java.util.Calendar
format.
I need to set both a start date and an end date which should 14 days in the future.
My Start Date is straight forward enough:
1. Calendar sd = Calendar.getInstance(); //this works
But I seem unable to produce a Calendar instance that is 14 days in the future. I know I can set the following:
2. sd.set(Calendar.Date, 14);
I do appreciate that this is probably a really trivial question - but how do I set this as a separate End Date Calendar variable?
e.g. Calendar ed = ? //when set to statement 2 - I get a compile error
Or am I approaching this in entirely the wrong way?
Thanks.