devxlogo

Using Calendar.getInstance()

Using Calendar.getInstance()

Calendar c = Calendar.getInstance();
c.set(2017, Calendar.OCTOBER, 29); 

This code behave as a Gregorian calendar, but if the returned Calendar subclass is a Islamic, Julian, Buddistic or Hebrew calendar, then the month called October or the year 2017, doesn’t exist. Calendar.getInstance() uses the current default locale to select an appropiate implementation. The utility of Calendar.getInstance() is very limited  and it should be avoided because it’s results is not properly defined.

Calendar c = new GregorianCalendar (timeZone);
c.set(2017, Calendar.OCTOBER, 29); 

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist