I have a requirement to obtain the current date/time, and the date/time 5 mins from now. I can successfully do this using a Calendar, however the API that I am calling requires the times in teh Date datatype.
I think I could do it by setting the calendar to the proper times (which I am doing now - see below), but not sure on the best way to convert this to Date type?
Would I be best to pass the Calendar out as a string and then parse this into a date? Or use the milliseconds from the calendar to set the date?
Or is there an even easier way to this? Cheers
Calendar right_now = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("d-MMMM-yyyy hh:mm");
System.out.println("Before Addition date is: " + formatter.format(right_now.getTime()));
Calendar five_mins = Calendar.getInstance();
System.out.println("After Addition date is: " + formatter.format(five_mins.getTime()));