File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes meaning? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "meaning?" Watch "meaning?" New topic


Donald Wynn

Joined: Dec 04, 2002
Posts: 29
I would like to know what this line of code means
Calendar cal = Calendar.getInstance(TimeZone.getDefault());
Andrew Fischer

Joined: Nov 18, 2002
Posts: 21
That line of code constructs a Calendar object initialized to the current date and time in the default time zone.

Sun Documentation for Calendar

Andrew Fischer
Donald Wynn

Joined: Dec 04, 2002
Posts: 29
What does that mean?
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
It is creating a variable named cal of type Calendar and then calling the constructor of the Calendar class using the "new" keyword to create an instance of Calendar that is looking at the PC that it is running on to find out what the default timezone for that PC is. If this is running on a server it would pick up the timezone for the server.
[ fixed small typo -ds ]
[ December 04, 2002: Message edited by: Dirk Schreckmann ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: meaning?
It's not a secret anymore!