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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:26:33+00:00 2026-06-15T06:26:33+00:00

I am using Joda Time 2.1 library. I have written a method to compare

  • 0

I am using Joda Time 2.1 library.

I have written a method to compare if a given date is between a date range of not. I want it to be inclusive to the start date and end date.I have used LocalDate as I don’t want to consider the time part only date part.

Below is the code for it.

isDateBetweenRange(LocalDate start,LocalDate end,LocalDate target){

       System.out.println("Start Date : "
              +start.toDateTimeAtStartOfDay(DateTimeZone.forID("EST"));

       System.out.println("Target Date : "
              +targettoDateTimeAtStartOfDay(DateTimeZone.forID("EST"));

       System.out.println("End Date : "
              +end.toDateTimeAtStartOfDay(DateTimeZone.forID("EST"));

       System.out.println(target.isAfter(start));

       System.out.println(target.isBefore(end));
}

The output of above method is :

Start Date: 2012-11-20T00:00:00.000-05:00
Target Date: 2012-11-20T00:00:00.000-05:00
End Date : 2012-11-21T00:00:00.000-05:00
target.isAfter(start) : false
target.isBefore(end) : true

My problem is target.isAfter(start) is false even if the target date and start are having the same values.

I want that target >= start but here it considers only target > start.
I want it inclusive.

Does it mean that isAfter method finds a match exclusively ?

I have gone through the javadoc for Joda Time, but didn’t found anything about it.

  • 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-15T06:26:35+00:00Added an answer on June 15, 2026 at 6:26 am

    Yes, isAfter is exclusive, otherwise it should probably have been named isEqualOrAfter or something similar.

    Solution: Use “not before” instead of “after”, and “not after” instead of “before”.

    boolean isBetweenInclusive(LocalDate start, LocalDate end, LocalDate target) {
        return !target.isBefore(start) && !target.isAfter(end);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to compare(finding remaining days and time between two days) using joda time.
I am using the Joda-Time library in Java, and have a date and time
I am using Joda-Time library to convert my String dates to a real date,
I am using Joda library to get time period passed since a given timestamp:
I have the following problem using Joda-Time for parsing and producing date and time
I have this simple code, using Joda-time. Works fine, but I have a problem.
I'm using the Joda-Time library with Java. I'm having some difficulty trying to turn
I'm using Hibernate & Joda Time, with support from the UserType library. I'm able
I'm using Joda time to get the time that has passed between 2 different
Using the joda-time-2.0 version library, I was wondering, which of this functions is better

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.