• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert Java.sql.Date to String or Java.util.Date  RSS feed

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am getting the date value from DB in the format of :yyyy-MM-dd.
Here my requirement is like I need to convert that to the format of :MM/dd/yyyy
So anybody can me help like how I can convert that java.sql.Date to either String or Java.util.Date

Thanks In Advance
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A java.sql.Date is already a java.util.Date, because class java.sql.Date is a subclass of java.util.Date.

Date objects do not have formats by themselves. To display a date in a specific format, you format it with a DateFormat object. For example:
 
Krish Yeruva
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jesper,
Thanks a lot. it is working
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!