Reputation: 31963
for diffInSec=10 it returns 01:00:10
I want just to get 00:00:10 I do not know where is that 1 hour comes from.
SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss");
t.setText(sdf1.format(new Date(diffInSec*1000))+"");
Upvotes: 0
Views: 39
Reputation: 23171
Doing new Date(diffInSec*1000); gives you a date object that corresponds to 10 seconds after the epoch (January 1, 1970, 00:00:00 GMT). When you're using the SimpleDateFormat, it's converting it from GMT to your local time zone (for me, doing sdf1.format(new Date(diffInSec*1000))
gives me 19:00:10 since I'm in GMT -5)
Upvotes: 1