how to compare formatted String with int

Hi i have two formatted String in this format "mm/dd/yyyy" for which I used the formatter.format method and the name are
events_start_date and events_end_date. I need to compare these two String with another String in this format date="20060416".
I need to create an if statement like this

if (events_start_date <=date && events_end_date>=date)Then{ }

Now how can I compare these two differnt format strings. Please help
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You need to turn them into Date and then do the comparision
royalcyberAuthor Commented:
How can I turn them into dates
DateFormat df1 = new SimpleDateFormat("MM/dd/yyyy" ):
DateFormat df2 = new SimpleDateFormat("yyyyMMdd" ):
Date d1 = df1.parse(s1); // 's' is String
Date d2 = df2.parse(s2);

You can now compare them. See java.util.Date javadoc
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

royalcyberAuthor Commented:
is the date or
royalcyberAuthor Commented:
I saw the javadoc for java.util.Date but there were methods like after, before and equals. Would you know how an I use these methods to acheive this result

 if((start <= date) && (end >= date){{}


if (end.compareTo(date) >= 0 && start.compareTo(date) <= 0)

> if (events_start_date <=date && events_end_date>=date)Then{ }

Date d = df.parse(date);

if (!(d.before(formatter.parse(events_start_date)) ||  d.after(formatter.parse(events_end_date)))
royalcyberAuthor Commented:
Thanks CEHJ

I am stuck with another question also.

I have two string month and year and I need to find out if the java.util.Date.start_event (only month and year) <= date && java.util.Date.end_event (only month and year) >= date

I concatenated the month and year Strings to one String date.

I tried using the getMonth() method and then compare the month and year seperately but the method is crossed out in JUilder and I am not able to use it

Please help

Set a Calendar to the Date and clear all but the month and year

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
use the following to get the month and year from a Date:

Calendar cal = Calendar.getInstance();

int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.