I have an issue with a Simple Date Format, I don't know why. This is my algorithm
if (realtimeDeparture != null) {
int hours = this.realtimeDeparture / 3600;
int minutes = (this.realtimeDeparture % 3600) / 60;
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm");
try {
Calendar cal = Calendar.getInstance(Locale.FRENCH);
String date = cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH)+1)+ "-" + cal.get(Calendar.DAY_OF_MONTH)+ " " + hours+":"+minutes;
result = df.parse(date);
}
I have an API which give me a number of seconds after 00h00 (realtimeDeparture) I want to extract from this integer a real Date Object So I did this algorithm but I loose hour I don't know why.
For example, there is some input and result value :
date = 2018-5-7 12:26
result = Mon May 07 00:26:00 GMT+02:00 2018
I tried to check if 07/05/2018 is different than 7/5/2018, but same issue :
date = 2018-05-07 12:26
result = Mon May 07 00:26:00 GMT+02:00 2018
How I can get my Date Object from a number of second from 00h00 ? Or how I can fix my algorithm ?