How to convert rome date format “Sun Jan 08 02:25:00 IST 2012” date to sql date
Question
I am using rome 0.9 for getting rss feeds.but from that getting blog post's date
as in the format "Sun Jan 08 02:25:00 IST 2012" .
I am unable to convert this date format to the sql date format.Actually i want to sort the blog posts according to the post date.
How to parse the date.
Solution
try this way,
String str_date = "Sun Jan 08 02:25:00 IST 2012";
SimpleDateFormat fmt = new SimpleDateFormat("E MMM dd hh:mm:ss Z yyyy");
Date today = null;
try {
today = (Date)fmt.parse(str_date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
java.sql.Date dt = new java.sql.Date(today.getTime());
System.out.println(dt.toString());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow