Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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 ]
 
What are your superhero powers? Go ahead and try them on this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!