• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Vivek Kr Agrawal
Ranch Hand
Posts: 51
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15480
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic