title: Does anyone know how to convert a datefield to a string in java j2me?
body: <p>I need to get the data from a datefield calender and be able to display it in a string and later store it in a recordstore. I tried the toString() method but i had an error once run.</p>
  
  <pre><code>        StartDate = new DateField("Start Date ", DateField.DATE);
          StartDate.setDate(Calendar.getInstance().getTime());
  </code></pre>
  
  <p>I now have this code </p>
  
  <pre><code>     public static String dateToString (long date)
      {
  
       Calendar c = Calendar.getInstance() ;
  
       c.setTime(new Date(date));
       int y = c.get(Calendar.YEAR);
       int m = c.get(Calendar.MONTH) + 1; 
       int d = c.get(Calendar.DATE);
       String t = (y&lt;10? "0": "")+y+"-"+(m&lt;10? "0": "")+m+"-"+(d&lt;10?
       "0": "")+d;
       return t;  
        }
  </code></pre>
  
  <p>How can I change this in order for this to get the date from Startdate and make that t.? </p>
  
  <p>If anyone could help!</p>