Java DateFormat getInstance() Method with Examples Last Updated : 16 Dec, 2022 Comments Improve Suggest changes Like Article Like Report The getInstance() method of DateFormat class will return the date and time formatter with the default formatting style for the default locale. Syntax: public static final DateFormat getInstance() Parameter: This method doesn't require any parameters. Return value: This method will return the date format in a particular format. Example 1: Java // Java program to illustrate // GetInstance() method // importing the required packages import java.text.DateFormat; import java.util.Date; class Testclass { public static void main(String[] args) { // initializing the Date Date d = new Date(); // initializing the DateFormat using getInstance() DateFormat df = DateFormat.getInstance(); // printing the DateFormat return value as object System.out.println("DateFormat Object : " + df); // formatting the current date into a string String str = df.format(d); // printing the current date System.out.println("Current date : " + str); } } OutputDateFormat Object : java.text.SimpleDateFormat@c88bcc54 Current date : 12/15/21, 8:23 AM We can also display the date in the required format using SimpleDateFormat class. Below is the example showing the use of SimpleDateFormat Example 2: Java // Java program to illustrate // GetInstance() method // importing the required packages import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; class Testclass { public static void main(String[] args) { // initializing the Date Date d = new Date(); // initializing the DateFormat using getInstance() DateFormat df = DateFormat.getInstance(); // printing the DateFormat return value as object System.out.println("DateFormat Object : " + df); // formatting the current date into a string String str = df.format(d); // printing the current date System.out.println("Current date : " + str); // initializing the SimpleDateFormat SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy"); // formatting the SimpleDateFormat into a string String st = sdf.format(d); // printing the formatted value System.out.println("Formatted Date : " + st); } } OutputDateFormat Object : java.text.SimpleDateFormat@c88bcc54 Current date : 12/15/21, 8:26 AM Formatted Date : 12-15-2021 Comment More infoAdvertise with us Next Article Java DateFormat getInstance() Method with Examples akashdeepkatari Follow Improve Article Tags : Java Java-Functions Java-DateFormat Practice Tags : Java Similar Reads DateFormat getTimeInstance() Method in Java with Examples DateFormat class of java.text package is an abstract class that is used to format and parse dates for any locale. It allows us to format date to text and parse text to date. DateFormat class provides many functionalities to obtain, format, parse default date/time. Note: DateFormat class extends Form 2 min read DateFormat getDateInstance() Method in Java with Examples DateFormat class of java.text package is an abstract class that is used to format and parse dates for any locale. It allows us to format date to text and parse text to date. DateFormat class provides many functionalities to obtain, format, parse default date/time. Note: DateFormat class extends Form 2 min read DateFormat getDateTimeInstance() Method in Java with Examples DateFormat class of java.text package is an abstract class that is used to format and parse dates for any locale. It allows us to format date to text and parse text to date. DateFormat class provides many functionalities to obtain, format, parse default date/time. Note: DateFormat class extends Form 2 min read Collator getInstance() method in Java with Example The getInstance() method of java.text.Collator class is used to get the new collator object having the current default locale. Syntax: public static Collator getInstance() Parameter: This method does not accept any parameter.Return Value: it provides the new collator object having the current defaul 2 min read Calendar getInstance() Method in Java with Examples The getInstance() method in Calendar class is used to get a calendar using the current time zone and locale of the system. Syntax: public static Calendar getInstance() Parameters: The method does not take any parameters. Return Value: The method returns the calendar. Below program illustrates the wo 1 min read DecimalFormatSymbols getInstance() method in Java with Examples The getInstance() method of java.text.DecimalFormatSymbols class in Java is used to get the DecimalFormatSymbols instance for the default Locale. This method is final and cannot be overridden or changed. Syntax: public static final DdecimalFormatSymbols getInstance() Parameter: This method do not ac 1 min read AlgorithmParameters getInstance() method in Java with Examples getInstance(String algorithm) The getInstance() method of java.security.AlgorithmParameters class returns an object of AlgorithmParameters type that applies the assigned AlgorithmParameters algorithm.Syntax: public static AlgorithmParameters getInstance(String algorithm) throws NoSuchAlgorithmExcept 4 min read Currency getInstance() Method in Java with Examples The getInstance() Method of Currency class in Java is used to retrieve the instance of this currency for a given currency code.Syntax: CURRENCY.getInstance(String currency_code) Parameters: This method accepts one parameter currency_code which is the currency of a particular currency.Return Value: T 2 min read Collator getInstance(Locale) method in Java with Example The getInstance(Locale) method of java.text.Collator class is used to get the new collator object having the desired locale. Syntax: public static Collator getInstance(Locale desiredLocale) Parameter: This method takes the desired locale for which collator object has to be created. Return Value: it 2 min read DecimalFormatSymbols getInstance(Locale) method in Java with Examples The getInstance(Locale) method of java.text.DecimalFormatSymbols class in Java is used to get the DecimalFormatSymbols instance for the specified Locale. This method is final and cannot be overridden or changed. It takes the Locale for which the DecimalFormatSymbols is required, as a parameter and r 1 min read Like