date.getHours() to calendar.hour
- by user1487045
I want to get the hour of day in 24hour cycle. I know that date.getHours() is depreciated. But I'm tempted to use it since I cant get the same result out of calendar.hour call. Can anyone tell me how to fix what I have below to get the hours out correctly with calendar.hour? ...much appreciated.
Date d = new Date();
Calendar c = Calendar.getInstance();
c.setTime(d);
System.out.println("hour: "+Math.abs(c.HOUR-24)+", mins: "+Math.abs(c.MINUTE-60)+", d.h: "+d.getHours() +", d.m: "+d.getMinutes());