• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SimpleDateFormat

 
Janne ukko
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SimpleDateFormat has output functions as well as input functions.

check the API docs... it's what they're there fore, learn to use them.
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is an explanation of how to use SimpleDateFormat.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic