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 1Test it NowOutput: 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 2Test it NowOutput: 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 3Test it NowOutput: 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 4Test it NowOutput: 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 5Test it NowOutput: 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 6Test it NowOutput: 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 Class
|