Get HOUR_OF_DAY value in >12 hrs format.

Discussion in 'Java' started by The One, Dec 20, 2006.

  1. The One

    The One Guest

    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
    The One, Dec 20, 2006
    #1
    1. Advertising

  2. The One

    Daniel Pitts Guest

    Re: Get HOUR_OF_DAY value in >12 hrs format.

    The One wrote:
    > 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.
    Daniel Pitts, Dec 20, 2006
    #2
    1. Advertising

  3. The One

    The One Guest

    Re: Get HOUR_OF_DAY value in >12 hrs format.

    Oh correct.

    It was a minor bug and I corrected that.

    Thanks for the help

    On Dec 19, 4:51 pm, "Daniel Pitts" <> wrote:
    > The One wrote:
    > > 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 DaveHello.

    >
    > 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.
    The One, Dec 21, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    330
    webMODULES
    Oct 5, 2006
  2. nitya

    24 hrs

    nitya, Mar 10, 2008, in forum: C++
    Replies:
    0
    Views:
    329
    nitya
    Mar 10, 2008
  3. carmen

    Converting hrs and min to just min

    carmen, Aug 10, 2004, in forum: ASP General
    Replies:
    4
    Views:
    132
    carmen
    Aug 10, 2004
  4. Pragash Mr.
    Replies:
    2
    Views:
    88
    Tachikoma
    Jul 17, 2008
  5. Robert

    Hrs of work on regex: please help

    Robert, Jul 27, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    136
    Gunnar Hjalmarsson
    Jul 29, 2004
Loading...

Share This Page