Why does this keep returning 0?
Calendar calendar = Calendar.getInstance();
calendar.get(Calendar.HOUR_OF_DAY)?
Why does this keep returning 0?
Calendar calendar = Calendar.getInstance();
calendar.get(Calendar.HOUR_OF_DAY)?
Calendar.HOUR_OF_DAY will be 0 whenever the hour of the day falls between between midnight and one o'clock in the morning. So chances are, either it is in that time interval wherever you are, or your Android emulator is set up so it thinks you're in that time interval.
If that's not the case, you could try setting the hour to some arbitrary value and then getting it again to check that it's working. To do that, try:
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 5);
Ideally it should not,
Try this
Calendar calendar = Calendar.getInstance();
System.out.println(calendar.get(Calendar.YEAR));
System.out.println(calendar.get(Calendar.HOUR));
System.out.println(calendar.get(Calendar.HOUR_OF_DAY));
System.out.println(calendar.get(Calendar.MINUTE));
Nothing different from what you have except I am trying to print year,hour, hour of day,minute.