Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>According to <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html" rel="noreferrer">Oracle Documentation</a> it is clearly mentioned that, </p> <blockquote> <p>public static Calendar getInstance()<br> Gets a calendar using the default time zone and locale. The Calendar returned is based on the current time in the default time zone with the default locale.</p> </blockquote> <p>And the <code>default time zone</code> is got by <code>public static TimeZone getDefault()</code> and it is mentioned in <a href="http://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getDefault()" rel="noreferrer">TimeZone.getDefault()</a> that</p> <blockquote> <p>Gets the default TimeZone for this host. The source of the default TimeZone may vary with implementation.</p> </blockquote> <p>It will return the <code>default</code> timezone set in your computer until and unless you have used <code>public static void setDefault(TimeZone zone)</code> function to set the <code>TimeZone</code> explicitly.</p> <p><strong>I believe the above explanation answers your both the question,</strong></p> <ol> <li>What is the default timezone of java.util.Calendar.?</li> <li>Why is my variable cal of type Calendar shows a time that is not IST or EST.?</li> </ol> <p><strong>EDIT:</strong> As per your edited question </p> <blockquote> <p>Why is cal of Calendar and date of Date() different?</p> </blockquote> <p>When you call <code>System.out.println(date);</code> then <code>toString()</code> function is invoked and if you look at <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/Date.java#Date.toString%28%29" rel="noreferrer">Source Code of Date</a> you will find that it returns 3 letters shorthand for timezone by invoking the <code>displayName</code> function of default time zone which is 3 letters shorthand in your case <code>EST</code>, which is <code>U.S. Eastern Standard Time (GMT-05:00) Indiana (East)</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload