| Author |
SimpleDateFormat
|
Janne ukko
Greenhorn
Joined: Nov 25, 2004
Posts: 10
|
|
Hello need some help ! i take in a String that looks like timePattern I just wonder how i change the output format when converting this if i make a print out on the result now i got Thu Nov 25 00:00:00 CET 2004 if i want for example 2004-11-30 12:33:35 how do i do that. String timePattern = "yyyy-MM-dd"; SimpleDateFormat formatter = new SimpleDateFormat(timePattern); Date fe=getDateInstance(formatter); Date d = null; try { d = formatter.parse(publishDate, new ParsePosition(0)); } catch (NullPointerException e) { } System.out.print(d) // gives Thu Nov 25 00:00:00 CET 2004
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
You are printing out the Date object, not the SimpleDateFormat object.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Janne ukko
Greenhorn
Joined: Nov 25, 2004
Posts: 10
|
|
|
but i want the correct date into the Date varible to send to a function that set a Date varible, how do i do that
|
 |
Simon Birch
Greenhorn
Joined: Dec 26, 2003
Posts: 21
|
|
The Date object contains an internal representation of the date, so it will have the correct value, regardless of the format you use to enter the date. For example Also, have a look at the Sun API Docs
|
 |
 |
|
|
subject: SimpleDateFormat
|
|
|