Wednesday, July 3, 2024
HomeLanguagesJavaCalendar getInstance() Method in Java with Examples

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 working of getInstance() Method of Calendar class:
Example:




// Java code to illustrate
// getGreatestMinimum() method
  
import java.util.*;
public class Java_Calendar_Demo {
    public static void main(String args[])
    {
        // Creating a calendar
        Calendar calndr = Calendar.getInstance();
  
        // Display the date and time
        System.out.print("The system"
                         + " date and time is: " + calndr.getTime());
    }
}


Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#getInstance()

Nokonwaba Nkukhwana
Experience as a skilled Java developer and proven expertise in using tools and technical developments to drive improvements throughout a entire software development life cycle. I have extensive industry and full life cycle experience in a java based environment, along with exceptional analytical, design and problem solving capabilities combined with excellent communication skills and ability to work alongside teams to define and refine new functionality. Currently working in springboot projects(microservices). Considering the fact that change is good, I am always keen to new challenges and growth to sharpen my skills.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments