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 6822827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:42:35+00:00 2026-05-26T21:42:35+00:00

What is the date format to get only hours in 12-hours format from this

  • 0

What is the date format to get only hours in 12-hours format from this time

 Thu Oct 20 13:12:00 GMT+02:00 2011

edit:

using this code

Date eventDate = tempAppointments.get(i).mStartDate
System.out.println(eventDate.toString());

// date pattern
DateFormat df = new SimpleDateFormat("hh:'00' a");//output : Wed Nov 09 11:00:00 GMT+02:00 2011


// get the start date with new format (pattern) 
String hours = df.format(tempAppointments.get(i).mStartDate.getDay());
System.out.print(hours);//output: 02:00 AM

return hours as

02:00 AM

but for the given time. it must be 02: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-26T21:42:36+00:00Added an answer on May 26, 2026 at 9:42 pm

    I’m not sure why you are passing date.getDay() (which is deprecated, by the way) into the formatter if you want the hour part.

    Try this:-

    Date date = new Date();
    System.out.println("Date: " + date);
    
    DateFormat df = new SimpleDateFormat("hh:'00' a");
    String hour = df.format(date);
    System.out.println("Hour: " + hour);
    

    The output:

    Date: Sat Nov 19 17:57:05 CST 2011
    Hour: 05:00 PM
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody help me get this date format like Fri, 01 Oct 22:26:23 +0200
How do I get the system date and time in this format: $systime=12/january/2010 10.30
I get date in proper format from the database but i get time in
I'm trying to change the date format I get from my webservice to a
i'm trying to get date from UIDatePicker (MM-dd format) and to check if its
This is my SQL code SELECT p.plant_name, sum(data.value_1) totalvalue_1 FROM (SELECT DISTINCT date_format(date, '%Y-%m')
Is it possible to format a date time in Java using the SimpleDateFormat class
given this code to retrieve the date from and date to : <dl> <dt><label
With ruby I'm trying to get format a date as such: 2009-10-01 Where I
Ok so I have managed to get the format of the date presented in

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.