• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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!!
 
Java Cowboy
Sheriff
Posts: 16081
88
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.
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!