wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes DateFormat class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "DateFormat class" Watch "DateFormat class" New topic
Author

DateFormat class

Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531


can anyone explain me what is happening here? what exactly does the format method do?

we have a date and we want to print it in different formats. so what does DateFormat class do? what is Dateformat.getInstance() doing?
Dejan Miler
Ranch Hand

Joined: Nov 14, 2009
Posts: 56
Since Dateformat class is abstract it cannot be instantiated Dateformat.getInstance() returns static instance of Dateformat class.
In another words Dateformat.getInstance() get a default date/time formatter that uses the SHORT style for both the date and the time.


SCJP 1.6 in progress ....
S Bhanage
Greenhorn

Joined: Oct 28, 2009
Posts: 13
Hi,

can anyone explain me what is happening here?


The code is creating a Date instance with value "Wed Dec 31 21:46:40 EST 1969"
The DateFormat is used to represent this date in various formats.

what exactly does the format method do?


Format returns formated time string in the form you specified while creating
DateFormat instance using "getInstance()" method.

we have a date and we want to print it in different formats. so what does DateFormat class do?


Yes you can do so. Refer to the API to know more details about DateFormat and its use.

what is Dateformat.getInstance() doing?


Get a default date/time formatter that uses the SHORT style for both the date and the time.
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: DateFormat class