Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6759001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:52:37+00:00 2026-05-26T13:52:37+00:00

I have some layout/button and onClick I get TimePickerDialog with current time (previously defined

  • 0

I have some layout/button and onClick I get TimePickerDialog with current time (previously defined from Calendar):

    RelativeLayout time = (RelativeLayout) findViewById(R.id.time_layout);
    time.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            TimePickerDialog dateDialog = new TimePickerDialog(SelectDateTimeActivity.this,
                    TimeSetListener,
                    hours, minutes, false);
            dateDialog.show();
        }
    });

TimePicker is in 12h mode – it has AM/PM mark. TimeSetListener looks like

private TimePickerDialog.OnTimeSetListener TimeSetListener = new TimePickerDialog.OnTimeSetListener() {
    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
        hours = hourOfDay;
        minutes = minute;
        updateTimeRow();
    }
};

and updateTimeRow() is

private void updateTimeRow() {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR, hours);
    c.set(Calendar.MINUTE, minutes);

    timeBody.setText("@ " + (String) (DateFormat.format("hh:mm aa", c.getTime())));
}

The problem is that time set in TimePickerDialog 06:00 PM (which really is 18:00, I checked via logging) I get 06:00 AM in my timeBody textView. If I set it to 06:00 AM (which really is 06:00) in timeBody textView I get 06:00 PM. Why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:52:38+00:00Added an answer on May 26, 2026 at 1:52 pm

    Use HOUR_OF_DAY in place of HOUR.

    c.set(Calendar.HOUR, hours);
    

    Replace it with:

    c.set(Calendar.HOUR_OF_DAY, hours);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problems getting some of my views aligned in a relative layout that
I have panel that is using group layout to organize some label. I want
I have a layout as follows: <div style=width: 300> <div style=width: 300>Some Content</div> </div
I have a border layout in ExtJS, The north region contains some HTML, but
I am have buttons like this: <button type=button class=img img_button_bla onclick=...>Bla!</button> The img class
I have the following code for my dialog box, I want to get some
I have a frame layout with some layout as the first element and another
I have a listview with each row containing some text and a delete button.
I have a layout for my list row with some text and a layout
I have this simple code, that makes a get to a webservice. For some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.