bobrivers2003
Technical User
I want to work out the time difference (in hours) between and and 18:00.
I have tried:
Date futDate = new Date("23/05/2006 18:00:00");
long currentTime = System.currentTimeMillis();
long futTime = futDate.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
sdf.setTimeZone((TimeZone.getTimeZone("GMT")));
long left = futTime - currentTime;
System.out.println(sdf.format(new Date(left)));
Two things:
If I run it at 12:48:00 the time difference will be 06:11:00 instead of 05:11:00, how to I get the correct hour?
Once I have the correct hour diffence how would I excract just the hour and assign to a var?
Any help would be greatly appreciated
Many Thanks
I have tried:
Date futDate = new Date("23/05/2006 18:00:00");
long currentTime = System.currentTimeMillis();
long futTime = futDate.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
sdf.setTimeZone((TimeZone.getTimeZone("GMT")));
long left = futTime - currentTime;
System.out.println(sdf.format(new Date(left)));
Two things:
If I run it at 12:48:00 the time difference will be 06:11:00 instead of 05:11:00, how to I get the correct hour?
Once I have the correct hour diffence how would I excract just the hour and assign to a var?
Any help would be greatly appreciated
Many Thanks