DateFormat getTimeInstance() Method in Java with Examples Last Updated : 24 Jan, 2022 Comments Improve Suggest changes Like Article Like Report 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 Format class that means it is a subclass of Format class. Since DateFormat class is an abstract class, therefore, it can be used for date/time formatting subclasses, which format and parses dates or times in a language-independent manner. Package-view: java.text Package DateFormat Class getTimeInstance() Method getTimeInstance() Method of DateFormat class in Java is used to get the time format. This time formatter comes with a default formatting style for a default locale. Syntax: public static final DateFormat getTimeInstance() Parameter: The method does not take any parameters. Return Type: The method returns a time formatted in a particular format. Example 1: Java // Java Program to Illustrate getTimeInstance() Method // of DateFormat Class // Importing required classes import java.text.*; import java.util.*; // Main class public class GFG { // Main driver method public static void main(String[] argv) { // Initializing the first formatter by // creating object of DateFormat class DateFormat DFormat = DateFormat.getTimeInstance(); System.out.println("Object: " + DFormat); // Formatting the string using format() method String str = DFormat.format(new Date()); // Displaying the formatted string time on console System.out.println(str); } } OutputObject: java.text.SimpleDateFormat@8400729 6:39:49 AM Example 2: Java // Java Program to Illustrate getTimeInstance() Method // of DateFormat Class // Importing required classes import java.text.*; import java.util.*; // Main class public class GFG { // Main driver method public static void main(String[] args) throws InterruptedException { // Initializing simple date format mm/dd/yyyy // by creating object of SimpleDateFormat class SimpleDateFormat SDFormat = new SimpleDateFormat("MM/dd/yyyy"); // Displaying the formats Date date = new Date(); String str_Date1 = SDFormat.format(date); // Displaying original date System.out.println("The Original: " + (str_Date1)); // Initializing the Time formatter DateFormat DFormat = DateFormat.getTimeInstance(); System.out.println("Object: " + DFormat); // Formatting the string using format() method String str = DFormat.format(new Date()); // Displaying the formatted string time on console System.out.println(str); } } OutputThe Original: 01/11/2022 Object: java.text.SimpleDateFormat@8400729 6:45:24 AM Comment More infoAdvertise with us Next Article DateFormat getTimeInstance() Method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java-Functions Java-text package Java-DateFormat +1 More Practice Tags : JavaMisc Similar Reads 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 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 Java DateFormat getInstance() Method with Examples 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 fo 2 min read DateFormat getTimeZone() Method in Java with Examples The getTimeZone() method in DateFormat class is used to return the current time-zone of the calendar of this DateFormat. Syntax: public TimeZone getTimeZone() Parameters: The method does not take any parameters. Return Value: The method returns timezone associated with the calendar of DateFormat. Be 1 min read DateFormat getCalendar() Method in Java with Examples The getCalendar() Method of DateFormat class in Java is used to get the calendar associated with this date/time format object. Syntax: public Calendar getCalendar() Parameter: The method does not take any parameters. Return Value: The method returns an instance of Calendar for this DateFormat object 2 min read Like