Dear All,
I have read dateTime field into a string from mysql database and in my java I have another dateTime in string format and in same format as the mysql date time and would like to compare both to see which one is before?

Recommended Answers

All 4 Replies

so ... what's stopping you from doing so?

Dear Stultuske,
I am not sure how to comparte now just to do a string comparison is it or must I format them back to Date type first?

If you want to know which date is earlier then yes, you need to convert both to Date. You can use the SimpleDateFormat class to convert/parse a string into a Date

Dear James,
Thank you for the confirmation. Ok I will try it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.