I have an alarm application and I store alarms into the databse. All alarms work well and the values (miliseconds) are stored as the correct number. Now I'm trying to display those times from my database. And I'm using a Calendar to retreive the time in the Time format :
Calendar calendar = Calendar.getInstance();
SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm");
milis = c.getInt(2);
calendar.setTimeInMillis(milis);
vreme = timeformat.format(calendar.getTime());
listavreme.add(vreme);
Milis are retrieved as the right number from the Cursor
(tested) but when I display the getTime()
in the HH:mm format it is always displayed with an extra hour. So if the milis value is : 61200000 (17:00), the calendar displays it as 18:00. I can't figure it out.
I think you have to set the TimeZone to you location try
timeformat.setTimeZone(TimeZone.getTimeZone("GMT"));
for example