my dog learned polymorphism
The moose likes Java in General and the fly likes Conversion of String(dd/mm/yyyy) into 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 "Conversion of String(dd/mm/yyyy) into format" Watch "Conversion of String(dd/mm/yyyy) into format" New topic

Conversion of String(dd/mm/yyyy) into 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 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: 15033

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:
subject: Conversion of String(dd/mm/yyyy) into format
jQuery in Action, 3rd edition