File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes difference between getInstance() and getDateInstance() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "difference between getInstance() and getDateInstance()" Watch "difference between getInstance() and getDateInstance()" New topic
Author

difference between getInstance() and getDateInstance()

Ben Zaidi
Ranch Hand

Joined: Apr 08, 2007
Posts: 151
Hi All,

I was looking forward to know what's the main difference between these two methods of DateFormat class

getInstance()
getDateInstance()

Can someone tell me any difference, because both appear to work the same way.

Ben


Ben,
--Lost in preparation of SCJP and SCWCD--
"Start writing a new chapter, for if you live by the book you'll never make history." (Ben Sobel)
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

Well getDateInstance and getInstance are mostly the same. But there is overloaded version of getDateInstance which can take parameter but getInstance is not overloaded to take parameters. Here's the docs for the no parameter version of both the methods

public static final DateFormat getInstance()

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


public static final DateFormat getDateInstance()

Gets the date formatter with the default formatting style for the default locale.


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: jrebel
 
subject: difference between getInstance() and getDateInstance()
 
Similar Threads
object creation- new v/s getInstance()
Factory methods
Class.forName() or Class.forName().getInstance()
Difference between Class.forName() and Class.forName().getInstance()
How can we count the number of objects created per class using Java1.5 API?