Convert and compare two date formats in JAVA

date, java, simpledateformat

Solution

If you want to compare two dates formatted differently,

- parse the first string with the appropriate date format to transform the string into a Date

- parse the second string with the appropriate date format to transform the string into a Date

- compare the Date objects

Problem

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.

Original source