File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes changing date format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "changing date format" Watch "changing date format" New topic
Author

changing date format

sumi sudha
Greenhorn

Joined: Jan 27, 2010
Posts: 14
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
Marshal

Joined: Mar 22, 2005
Posts: 42600
    
  65
Welcome to JavaRanch.

That's what the java.text.DateFormat and SimpleDateFormat classes do; see http://faq.javaranch.com/java/JavaDatesFaq for examples.


Ping & DNS - my free Android networking tools app
Ramesh Kumar
Ranch Hand

Joined: Oct 29, 2008
Posts: 42
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

SCJP,OCA
sumi sudha
Greenhorn

Joined: Jan 27, 2010
Posts: 14
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

Joined: Jan 28, 2008
Posts: 5575

sumitha sudhakar wrote: have to convert the string to date and with the same format.


Already Ulf and Ramesh mentioned clearly.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42600
    
  65
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

Joined: Jan 27, 2010
Posts: 14
Hi Ulf,

I have solved my issues. Thanks a lot...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: changing date format