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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:28:51+00:00 2026-06-13T14:28:51+00:00

I have a time in 24 hour format 14:00:00. For this date i want

  • 0

I have a time in 24 hour format “14:00:00”.
For this date i want to generate date like if current time is less then 14:00:00 then today’s date else next day’s date.

so for “14:00:00”
if current date time is “30-10-2012 13:00:00” than I want 30-10-2012
else if current date time is “30-10-2012 15:00:00” than I want 31-10-2012

I tried this method that gives today’s date

public static String GetTodayDateTimeStamp(String time)
{
    String toReturn = "";

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();
    String toDayDate = dateFormat.format(date);

    toReturn = toDayDate + " " + time;

    return toReturn;
}
  • 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-06-13T14:28:52+00:00Added an answer on June 13, 2026 at 2:28 pm

    When creating a new Date object, the current time will be assigned to it. If you create two of those objects and set the hour to 14 and the minutes, seconds (and milliseconds if you must) to 0 with the use of a Calendar instance you’ll have the two dates you have to compare:

    Date now = new Date();
    Date today14pm = new Date();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(today14PM);
    calendar.set(Calendar.HOUR_OF_DAY, 14);
    calendar.set(Calendar.MINUTES, 0);
    calendar.set(Calendar.SECONDS, 0);
    calendar.set(Calendar.MILLISECONDS, 0);
    today14pm = Calendar.getTime();
    
    if(now.after(today14pm)) {
        //Generate tomorrow's date    
    } else {
        //Generate today's date
    }
    

    Just in case, you might want to set the lenient attribute of the calendar to true.

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

Sidebar

Related Questions

I have time in NSString like 15:15 I want to covert this NSString time
i have this long code to show today's date & time in a form
I have an ArrayCollection that I'd like to sort by date and then time
Now it's like this, I have a long variable with date and time on
In my code, I have this loop, which brings up various 2-hour time blocks.
So I have a php file called Time.php: <?php echo (( $DateTime.date(n/j/Y g:i:s A).Hour
I have a field that has time and date in following format 2010-03-26 10:06:11
I have something like below- EXTRACT(HOUR from CAST(to_char(tran_datetime,'DD-MON-YYYY HH24:MI:SS') AS TIMESTAMP)) tran_datetime is DATE
I have one question. How to convert that format 20110711201023 of date and time,
I have an Excel 2007 spreadsheet with date entries in this format m/d/yyyy h:mm

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.