aspose file tools
The moose likes Java in General and the fly likes string to date conversion problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "string to date conversion problem" Watch "string to date conversion problem" New topic
Author

string to date conversion problem

mihir maniar
Ranch Hand

Joined: Sep 09, 2003
Posts: 88
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?
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
You can, explore the java.text.SimpleDateFormat class.


Sharing is learning
mihir maniar
Ranch Hand

Joined: Sep 09, 2003
Posts: 88
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

Joined: Nov 28, 2001
Posts: 233
SimpleDateFormat dtFormat1 = new SimpleDateFormat("ddMMyyyy");
dt = dtFormat1.parse("02052006");
System.out.println("date is " + dt);
[ May 02, 2006: Message edited by: Arun Boraiah ]
 
I agree. Here's the link: jrebel
 
subject: string to date conversion problem
 
Similar Threads
Parse A Date String
sql date convert
please explain every line
convert timestamp to date
first date and last date of month