Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Currently, the <a href="http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#toString()" rel="nofollow noreferrer"><code>Date.toString()</code></a> method is being called to display the <code>String</code> representation of the <a href="http://java.sun.com/javase/6/docs/api/java/util/GregorianCalendar.html" rel="nofollow noreferrer"><code>GregorianCalendar</code></a> instance.</p> <p>What needs to be done is to create a <a href="http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html" rel="nofollow noreferrer"><code>DateFormat</code></a> which will produce a <code>String</code> representation which is desired. The <code>DateFormat</code> object can be used to format a <code>Date</code> instance to the desired formatting using the <a href="http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html#format(java.util.Date)" rel="nofollow noreferrer"><code>format</code></a> method.</p> <p>The simplest way to achieve what is desired is to use the <a href="http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html" rel="nofollow noreferrer"><code>SimpleDateFormat</code></a> class, which has a <a href="http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#SimpleDateFormat(java.lang.String)" rel="nofollow noreferrer">constructor which takes a format string</a> to output the <code>Date</code> in a desired form.</p> <pre><code>Calendar calendar = new GregorianCalendar(2009, Calendar.JANUARY, 1); DateFormat df = new SimpleDateFormat("M/d/yyyy"); System.out.println(df.format(calendar.getTime())); </code></pre> <p>Output</p> <pre><code>1/1/2009 </code></pre>
    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. 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.
 

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