Java Calendar getInstance() MethodThe getInstance() method of java.util.Calendar class is a Static method. This method is used with calendar object to get the instance of calendar according to current time zone set by java Runtime environment. SyntaxParameterLocale and TimeZone are passed as parameters. ReturnsReturns Calendar . ThrowsDoes not throw exception. Example 1Output: mycal1 :Sat Aug 04 14:54:57 PDT 2018 mycal2 :Wed Oct 23 14:54:57 PDT 1996 both the instance of calendat are not equal Example 2Output: mycal1 :Sat Aug 04 15:01:45 PDT 2018 mycal2 :Sat Aug 04 15:01:45 PDT 2018 both the instance of calendat are not equal mycal1 :Thu Jan 01 00:00:00 PST 1970 mycal2 :Thu Jan 01 00:00:00 PST 1970 Example 3Output: mycal1 :Sat Aug 04 23:23:00 PDT 2018 mycal2 :Wed Oct 23 23:23:00 PDT 1996 both the instance of calendat are not equal Example 4Output: mycal1 :Sat Aug 04 23:25:44 PDT 2018 mycal2 :Sat Aug 04 23:25:44 PDT 2018 both the instance of calendat are not equal mycal1 :Thu Jan 01 00:00:00 PST 1970 mycal2 :Thu Jan 01 00:00:00 PST 1970 Example 5Output: mycal1 :Sun Aug 05 00:00:08 PDT 2018 mycal2 :Sun Aug 05 00:00:08 PDT 2018 both the instance of calendar are not equal mycal1 :Wed Dec 31 16:00:00 PST 1969 mycal2 :Wed Dec 31 16:00:00 PST 1969 Example 6Output: mycal1 :Sun Aug 05 00:01:38 PDT 2018 mycal2 :Wed Oct 23 00:01:38 PDT 1996 both the instance of calendar are not equal Next TopicJava-calendar-getleastmaximum-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India