aspose file tools*
The moose likes Java in General and the fly likes Conversion of String(dd/mm/yyyy) into java.sql.date format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Conversion of String(dd/mm/yyyy) into java.sql.date format" Watch "Conversion of String(dd/mm/yyyy) into java.sql.date format" New topic
Author

Conversion of String(dd/mm/yyyy) into java.sql.date format

Vivek Kr Agrawal
Ranch Hand

Joined: Sep 08, 2012
Posts: 51

I am taking a string in textBox in format(dd/mm/yyyy). Now i have to convert it in format java.sql.date to store in Oracle Database whose datatype is again date.
Thanks in advance!!


Vivek Agrawal
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

Use class java.text.SimpleDateFormat to parse the string into a java.util.Date object.

If you're inserting it into the database using JDBC, you'll have to convert that to a java.sql.Date (unfortunately, there are two classes called Date - one in the package java.util and another in the package java.sql). Converting from java.util.Date to java.sql.Date is easy - have a look at the constructors of java.sql.Date and the methods of java.util.Date in the documentation.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conversion of String(dd/mm/yyyy) into java.sql.date format