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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:28:48+00:00 2026-05-30T11:28:48+00:00

I would like to have two functions: Say I have the date in a

  • 0

I would like to have two functions:

  1. Say I have the date in a string "11/12/2011" and time in a String: "0200". I would like a simple function (if possible) that takes two parameters (the date and time from above) in java that converts it into 11/12/2011 2:00AM in a Java Date object.

  2. Say I have a java Date object as the only parameter (e.g. 11/12/2011 2:00AM) that returns the military time from it, (e.g. “0200”).

Is there some java library or what is the best way to accomplish the above? Or is there something built into java Date that makes it easy to get something in military time to normal time Java date uses?

  • 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-30T11:28:49+00:00Added an answer on May 30, 2026 at 11:28 am
    new SimpleDateFormat("MM/dd/yyyy HHmm").parse("11/12/2011" + " " + "0200");
    new SimpleDateFormat("MM/dd/yyyy HHmm").format(new Date());
    new SimpleDateFormat("HHmm").format(new Date());
    

    (assuming the military in the US still put month first in dates).

    [edit: you need to worry about your time zone too – for parsing it’s often easiest to simply append this. for example:

    new SimpleDateFormat("MM/dd/yyyy HHmm Z").parse("11/12/2011" + " " + "0200" + " PST");
    

    (maybe the military always use UTC? i have no idea…). and for formatting, you can set the timezone on the SDF instance using setTimezone().]

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

Sidebar

Related Questions

I have two span elements that I would like to stay on the same
I have two classes that I would like to merge into a composite. These
I have two arrays that I would like to compare and ultimately wind up
I have two LINQ statements that I would like to make into one, but
I have two views that I would like to combine into one. The first
Let's say for example that I have two functions with random code inside and
I have two classes Invoice and InvoiceItem. I would like Invoice to have a
I have two hashmaps and I would like to fill a third hashmap which
I have two times in PHP and I would like to determine the elapsed
I have two ICollection s of which I would like to take the union.

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.