How to convert from Date(10-Oct-2014 00:00:00) to String in Java -
this question has answer here:
- how compare dates in java? 11 answers
- converting date-string different format 5 answers
i want compare 2 date values in java
date date1=10-oct-2014 00:00:00(value fetched db) date date2=10-oct-2014 00:00:00(value fetched db)
how convert date values string format in java cant compare them or else there way can compare these dates.
i compare long values of both dates this: if dates nullable dont forgett nullcheck!
if (date1!=null && date2 != null){ if (date1.gettime() == date2.gettime()){ system.out.println("dates equal"); } }
there no need cast date objects string objects.
Comments
Post a Comment