Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
DateFormat usage
liliya woland
Ranch Hand
Posts: 134
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello everyone,
Can some one tell me what do I need to add to this comand:
String
date = DateFormat.getDateInstance().format(rs.getDate(1));
in order to get date in the form yyyy-mm-dd ?
P.S rs.getDate(1) returns date as yyyy-mm-dd hh:mm:ss.ms
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
liliya, please take the time to choose the appropriate forum for your questions. This forum is for questions on
JSP
.
I've moved this topic to the
Java
in General (intermediate) forum.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Ulf Dittmer
Rancher
Posts: 43081
77
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
getDate does not return the date in any particular format; maybe what you're seeing is what it prints if its toString method is invoked.
A simple way would be to remove everything from the space characters on, i.e. rs.getDate(1).substring(0,10).
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Check out the SimpleDateFormat class and apply an appropriate
pattern
.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
liliya woland
Ranch Hand
Posts: 134
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks a lot to both of you.
Kevin Huang
Greenhorn
Posts: 13
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
If d is of type Date, then:
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(d);
upper case "MM".
ice is for people that are not already cool. Chill with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
why what i search is not what i want?
Code review required for converting dateformat
date format
How to fetch Date Field from excel sheet in Java
[log4j] DailyRollingFileAppender
More...