Comparing java utilDate with LocalDate in java

0 votes

I have a method wherein have to check whether aLocalDate falls in between two java.util.Date values. there are methods after and before in java.util.Date and there are methods isAfter and isBefore in LocalDate.

The code snippet which i have is as :

 /**
 * checks if date passed falls between start & end date
 *
 * @param date
 * @param startDate
 * @param endDate
 * @return
 */
public static boolean isBetween(Date date, Date startDate, Date endDate) {
    return (startDate == null || date.after(startDate) || date.equals(startDate))
            && (endDate == null || date.before(endDate) || date.equals(endDate));
}

There is no method in the API to compare across..

Apr 21 in Java by Rahul
• 2,540 points
14 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java

+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 58,920 views
0 votes
1 answer

How to pad an integer with zeros on the left in Java?

Use java.lang.String.format() method. String.format("%05d", number ...READ MORE

answered May 31, 2018 in Java by Daisy
• 8,120 points
1,442 views
0 votes
4 answers

How can we display an output of float data with 2 decimal places in java? Please help

You can use DecimalFormat. One way to use ...READ MORE

answered Dec 16, 2020 in Java by Gitika
• 65,850 points
64,034 views
0 votes
2 answers

How to left pad a string with zero in java?

String paddedString = org.apache.commons.lang.StringUtils.leftPad("129018", 10, "0") the second ...READ MORE

answered Aug 31, 2018 in Java by Sushmita
• 6,900 points
2,107 views
0 votes
1 answer

Join array elements with a separator in Java

Using Java 8, you can easily perform ...READ MORE

answered Aug 16, 2018 in Java by geek.erkami
• 2,680 points
555 views
0 votes
1 answer

Replace String with another in java

String s = "HelloSuresh"; s = s.replace("Hello",""); System.out.pri ...READ MORE

answered Aug 21, 2018 in Java by Parth
• 4,630 points
250 views
0 votes
1 answer

Executing commands with parameters in Java

Try using the below command: Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php", "-m", ...READ MORE

answered Sep 5, 2018 in Java by geek.erkami
• 2,680 points
1,384 views
0 votes
1 answer

Comparing Functions in Java

I would suggest that Version 1 is ...READ MORE

answered Jan 9, 2019 in Java by developer_1
• 3,310 points
147 views
0 votes
1 answer

What are the different ways of comparing Strings in Java?

The different ways of comparing string in ...READ MORE

answered Mar 5, 2019 in Java by Wasim
355 views
0 votes
1 answer

Replace all 0's with 5 in Java

Take a look at this, hope this ...READ MORE

answered Mar 6, 2019 in Java by Priyaj
• 58,060 points
3,494 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP