Reputation: 4811
In my application I am having two different types of date formats. One gives Thu Apr 19 12:10:26 GMT+05:30 2012 as out put and other one gives 1334654035000 as out put.
Can I change the first format to the second type (which has only numbers) ? The reason is,I have to compare two different dates.
Upvotes: 4
Views: 5010
Reputation: 7
parse the date and and compare the date
if(!sToDate[Integer.valueOf(sChecked[i])].equalsIgnoreCase("")&&!sFromDate[Integer.valueOf(sChecked[i])].equalsIgnoreCase(""))
if(sToDate[Integer.parseInt(sChecked[i])].compareTo(sFromDate[Integer.parseInt(sChecked[i])])<0)
Upvotes: 0
Reputation: 5427
Yes. You could do it. If we assume the dates are under the same time zone, convert the dates using SimpleDateFormat class to Calendar and then invoke the methods on Calendar object to compare dates.
Upvotes: 0
Reputation: 5130
using the parse method of java.text.SimpleDateFormat should do what you want
Upvotes: 0
Reputation: 691805
If you want to compare two dates formatted differently,
Upvotes: 3