Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Beginning Java
Convert Java.sql.Date to String or Java.util.Date
Krish Yeruva
Ranch Hand
Posts: 60
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Thanks & Regards
KITTU
Jesper de Jong
Java Cowboy
Posts: 16084
88
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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:
Date date = ...; // wherever you get this from DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); String text = df.format(date); System.out.println("The date is: " + text);
Jesper's Blog
-
Pluralsight Author Page
Krish Yeruva
Ranch Hand
Posts: 60
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Jesper,
Thanks a lot. it is working
Thanks & Regards
KITTU
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Problems setting sql Date in prepared statement
Convert Calendar to String
convert a string to java.sql.Date object
How to know if is a date
can java.sql.Date in different Date pattern ?
More...