I am having some trouble using the calendar class in android. How can I get the current time in 24 format?
Calendar c1 = Calendar.getInstance();
if You want 12 Hour Format Use - c1.set(Calendar.HOUR, new Date().getHours());
if You want 24 Hour Format Use - c1.set(Calendar.HOUR_OF_DAY, new Date().getHours());
Use Calendar.HOUR_OF_DAY
for getting hour in 24 format
Calendar rightNow = Calendar.getInstance();
int currentHour = rightNow.get(Calendar.HOUR_OF_DAY);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With