• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

changing date format

 
sumi sudha
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am having a String "21-MAY-09"
I need to create a Date from the above string and also with the same format as the String
Let me know for your valuable inputs
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

That's what the java.text.DateFormat and SimpleDateFormat classes do; see http://faq.javaranch.com/java/JavaDatesFaq for examples.
 
Ramesh Kumar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI

SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
Date date = sdf.parse("21-MAY-09") ;
This will returnt the corresponding Date Object ,,, and
String strDate = sdf.format(date);
This will return the corresponding String Format.

Hope you clear

Rameshkumar
 
sumi sudha
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the inputs. But my problem is, i need to give the formatted date as a input param to the callable statement . since in front end they have used string, have to convert the string to date and with the same format. but formatting a date returns string.

cstmt.setDate(date); where date should come from a stirng and with the same format as string.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sumitha sudhakar wrote: have to convert the string to date and with the same format.


Already Ulf and Ramesh mentioned clearly.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Date objects do not have a format. JDBC should take care of converting it to a DB-compatible format. What actual problem are you facing?
 
sumi sudha
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

I have solved my issues. Thanks a lot...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic