04-12-2013 04:53 AM
i have date coloum in database, and i' have retrieve that date from my database. the format of my date in my database is 31/01/2013, now i want to convert that format into 31 Janurary 2013.can u help me..?
04-12-2013 05:18 AM
04-12-2013 05:52 AM
yes i got the date from my Sql database by using
System.out.println("DATEEEEE=="+row.getObject(3)); //like 04/04/2013
String date = ""+row.getObject(3);
and i have put it into a string date.
now i want to convert ot into 04 April 2013
04-12-2013 06:27 AM
The only two methods I am aware of to convert a String to a Date are:
a) Use HttpDateParser, if your String matches the formats it supports
b) Hand craft a conversion yourself, which is pretty easy if long winded using a Calendar Object and extracting the components (month, day, year) from the String, and set ing these in the Calendar Object. Don't forget for a Calendar Object, Month 0 is January.
04-12-2013 06:36 AM - edited 04-12-2013 06:38 AM
yes i have use HttpDateParser but that was giving me wrong output
String date = ""+mr.getObject(3).toString();
/*Date eventDate = new Date(HttpDateParser.parse(date));
SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
String eventDateString = dateFormat.format(eventDate);
System.out.println("raw date=" + date + ", parsed string=" + eventDateString);
here i have date 04/02/2013(from my database)
and my converted is showing 01 January 1970
04-12-2013 06:44 AM - edited 04-12-2013 06:45 AM
I've not checked, but I suspect that means your format is not supported - review the API.
I guess you will have to use method (b) from my previous post.
04-12-2013 06:48 AM
04-12-2013 06:59 AM