File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes SimpleDateFormat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "SimpleDateFormat" Watch "SimpleDateFormat" New topic
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
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
SimpleDateFormat has output functions as well as input functions.

check the API docs... it's what they're there fore, learn to use them.


42
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Here is an explanation of how to use SimpleDateFormat.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SimpleDateFormat
 
Similar Threads
converting string yyyy/MM/dd to java.util.Date
SimpleDateFormat
Date format
SimpleDateFormat
Can someone please help me parse this date