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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:42:21+00:00 2026-05-24T18:42:21+00:00

Could please anybody explain to me, how DateTime works in regards to AM/PM ?

  • 0

Could please anybody explain to me, how DateTime works in regards to AM/PM ?

public DateTime(
        int year,
        int monthOfYear,
        int dayOfMonth,
        int hourOfDay,
        int minuteOfHour,
        int secondOfMinute,
        int millisOfSecond,
        DateTimeZone zone) {
    super(year, monthOfYear, dayOfMonth,
          hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond, zone);
}

I know that I could handle AM/PM via DateFormat and parsing string, but I’m interested in this method. I can’t figure this out. Because DateTimeZone doesn’t relate directly to Locale, Chronology does not too.

Do I have to manually change the hourOfDay based on AM/PM information into the 24 hours type ?

I’m working with a UI html form widget >> http request 6 parameters, based on Locale (y,m,d,h,m,AM/PM) / (y,m,d,h,m) >> now I’d like to create Date object from these 5/6 values via JodaTime’s DateTime object. Is it possible without me manually having to convert (y,m,d,h,m,AM/PM) to (y,m,d,h,m) ?

Manually I’d do that like this

public static Date getDateSinceUTC2(Target orderBean, TimeZone tz) {

    int ap = orderBean.getDeadLineAmPm();
    int year = orderBean.getDeadLineYear();
    int month = orderBean.getDeadLineMonth();
    int day = orderBean.getDeadLineDay();
    int hour = orderBean.getDeadLineHour();
    int minute = orderBean.getDeadLineMinute();

    if (ap == 1) {
        hour += 12;
    }

    month++;

    DateTime dt = new DateTime(year, month, day, hour, minute, 0, 0, DateTimeZone.forID(tz.getID()));

    return new Date(dt.getMillis());
}
  • 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-24T18:42:22+00:00Added an answer on May 24, 2026 at 6:42 pm

    Firstly, I would start off using LocalDateTime unless you’ve actually got a time zone.

    But you could create either a DateTime or a LocalDateTime by giving it any hour, and then using:

    // I'm assuming amPm is 0 for am and 1 for pm
    result = original.withField(DateTimeFieldType.hourOfHalfDay(), hour)
                     .withField(DateTimeFieldType.halfDayOfDay(), amPm);
    

    I think I’d personally probably perform the conversion to “hour of 24-hour day” myself though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could anybody explain the following code return total ?? decimal.Zero please? public decimal GetTotal()
Could someone please explain why this is happening? var y = new int[]{1,2}; Console.WriteLine(y
Hey, I'm talking about profiles within pom.xml of a project. Could please anybody explain
could please anybody explain, how POST request should be mapped properly ? it is
Could anybody please explain how the Core Classloader loads resources when, for instance, surefire
Can anybody please explain how this could possibly happen? I am completely aware of
Is anybody could explain when and why we should use System.ComponentModel.Container , please? Recently
With reference to this question , could anybody please explain and post example code
Could please anybody explain what are pros and cons of this? I mean, without
Wondering if someone could please explain the difference between these two queries and advise

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.