This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have one date as String s = message[i].getSentDate().toString() and another one is Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE,-1); SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd 'at' 14:00:00"); fmt.format(cal.getTime()); I want to put fmt.format(cal.getTime()) in a variable and compare it with s. I would like to know if the date is less or greater than the other. Whats the best way to do it Thanks, Vidhya
I suggest to convert both the object to Date object. Date class implements Comparable interface which has a method called compareTo(Object o). Using the method, one can compare two Date object. -------------- Nayan