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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:27:33+00:00 2026-05-29T06:27:33+00:00

I have a date with the format 2012-02-02(yyyy-MM-dd). For example if todays date is

  • 0

I have a date with the format 2012-02-02(yyyy-MM-dd).

For example if todays date is 2012-02-02 i need to add one and a half days to it which would make it 2012-02-03 06:00:00.0.

And if i have a number of dates of the following format 2012-02-03 06:30:00.0(yyyy-MM-dd HH:MM:SS.SSS) , i need to compare if all these dates are less than,greater than or equal to the date to which one and a half days were added above.

The comparison should also take care of the hours while comparing if the dates are less than,greater than or equal or equal to the other date and time.

How do i achieve the same.

  • 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-29T06:27:35+00:00Added an answer on May 29, 2026 at 6:27 am

    well so i hope this will give you a clear idea. Calendar Documentation and SimpleDateFormat Documentaion

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String aDateString = "2012-02-02";
    Date date = sdf.parse(aDateString);
    System.out.println("reference date:"+date);
    
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.add(Calendar.HOUR, 36);
    System.out.println("added one and half days to reference date: "+cal.getTime());
    
    String newDateString = "2012-02-03 06:30:00.0";
    sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
    Date newDate = sdf.parse(newDateString);
    System.out.println("new date to compare with reference date : "+newDate);
    
    Calendar newCal = Calendar.getInstance();
    newCal.setTime(newDate);
    
    if(cal.after(newCal)){
        System.out.println("date is greater than reference that.");
    }else if(cal.before(newCal)){
        System.out.println("date is lesser than reference that.");
    }else{
        System.out.println("date is equal to reference that.");
    }
    

    OUTPUT :

    reference date:Thu Feb 02 00:00:00 IST 2012
    added one and half days to reference date: Fri Feb 03 12:00:00 IST 2012
    new date to compare with reference date : Fri Feb 03 06:30:00 IST 2012
    date is greater than reference that.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Input Date Format DD-MM-YYYY Example 15-01-2012 I have a booking date stored in Session
I have a date string, for example: 2012-04-09T23:57:44.070Z My date format is: [dateFormatter setDateFormat:@yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'];
I have a date coming in. So for example 02/16/2012. What I need to
I have date, for example: 2012-02-07 14:09:46.109950 and I need timestamp as 1328623786.568740 ,
I have Date in this format (2012-11-17T00:00:00.000-05:00). I need to convert the date into
I have a date in the format MM/DD/YYYY. I need to then convert it
I have the following date format: Tue Mar 06 17:45:35 -0600 2012 and I
I have a date in NSString format with this content: 29/02/2012 12:00:00 AM I'm
I have a date as follows. $discount_start_date='03/27/2012 18:47'; $start_date=new DateTime($discount_start_date); $start_date->format('Y/m/d H:i:s'); How can
I'm trying to validate mm-dd-(2012~2099) date format. I have the following regular expression. ^(0[1-9]|1[0-2])-(0[1-9]|[10-31])-(20[12-99])$

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.