Get HOUR_OF_DAY value in >12 hrs format.

T

The One

Hi

I am using the Calendar object to get the value of the current hour.
here is the code:

TimeZone myTimeZone = TimeZone.getTimeZone("EST");
Calendar calendar = Calendar.getInstance(myTimeZone);
int currentHour = calendar.get(Calendar.HOUR_OF_DAY);

But here the currentHour variable gets value in between 1:12 after that
the clock is reset. Is there any specific property that I can set in
the JAva code. so I can work with 24 hours format.

Any help will be appreciated.

Thanks
Ankit Dave
 
D

Daniel Pitts

The said:
Hi

I am using the Calendar object to get the value of the current hour.
here is the code:

TimeZone myTimeZone = TimeZone.getTimeZone("EST");
Calendar calendar = Calendar.getInstance(myTimeZone);
int currentHour = calendar.get(Calendar.HOUR_OF_DAY);

But here the currentHour variable gets value in between 1:12 after that
the clock is reset. Is there any specific property that I can set in
the JAva code. so I can work with 24 hours format.

Any help will be appreciated.

Thanks
Ankit Dave
Hello.

calendar.get(Calendar.HOUR_OF_DAY) returns values from 0 to 23. There
may be some bug somewhere else in your code.

If you give us a short, simple compilable example that reproduces your
problem, we might be able to give much better advice.

Good luck.

-
Daniel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top