Create DateField for Date : DateField « J2ME « Java Tutorial






Create DateField for Date
import java.util.Calendar;

import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;

public class DateFieldSetDate extends MIDlet {
  protected Display display;

  protected void startApp() {
    display = Display.getDisplay(this);

    Form form = new Form("Demo");

    form.append("line");

    DateField timeOnly = new DateField("Time", DateField.DATE);
    timeOnly.setDate(Calendar.getInstance().getTime());
    form.append(timeOnly);

    display.setCurrent(form);
  }

  protected void pauseApp() {
  }

  protected void destroyApp(boolean unconditional) {
  }
}








31.6.DateField
31.6.1.Add DateField with current time to a formAdd DateField with current time to a form
31.6.2.Create DateField for DateCreate DateField for Date
31.6.3.Create DateField for Date and Time
31.6.4.Use DateFieldUse DateField
31.6.5.Today's date in DateFieldToday's date in DateField