I'm using SimpleDateFormat to get the hours and seconds in this format "HH:MM a" for 2 dates in same function. The output printing is same for both of them and it is mostly of the first date. The code for it is as follows:
//to get the time
public static void getHourAndTime(Date startDate, Date endDate){
SimpleDateFormat formatter = new SimpleDateFormat("HH:MM a");
String formattedstartTime = formatter.format(startDate);
System.out.println("startTime"+formattedstartTime);
String formattedEndTime = formatter.format(endDate);
System.out.println("endTime"+formattedEndTime);
}
Any solution/ reason for this would be helpful.
Edit: this was a piece of an old code in the application, that I was trying to change.
Thanks