• Post Reply Bookmark Topic Watch Topic
  • New Topic

string to date conversion problem  RSS feed

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a string in the format "01022006" which should get converted to date object and give me the date as 02-01-2006. i.e. 2nd Jan 2006. How can i achieve this?
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can, explore the java.text.SimpleDateFormat class.
 
mihir maniar
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i try the following code it tells me unparseable date "01022006". could you pls help me the exact area where it is causing the problem and help me rectify it. thx.

String strDate=new String("01052006");
Date d = DateFormat.getDateInstance().parse(strDate);
out.println(d.toString());
 
Arun Boraiah
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SimpleDateFormat dtFormat1 = new SimpleDateFormat("ddMMyyyy");
dt = dtFormat1.parse("02052006");
System.out.println("date is " + dt);
[ May 02, 2006: Message edited by: Arun Boraiah ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!