J2ME Java Tutorial

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
public class DateFieldMIDlet extends MIDlet implements CommandListener {
  private Command exitCommand;
  private DateField dateDateField = new DateField("date:", DateField.DATE);
  private DateField timeDateField = new DateField("time:", DateField.TIME);
  private DateField bothDateField = new DateField("both:", DateField.DATE_TIME);
  private Display display;
  public DateFieldMIDlet() {
    display = Display.getDisplay(this);
    exitCommand = new Command("exit", Command.EXIT, 1);
    java.util.Date now = new java.util.Date();
    dateDateField.setDate(now);
    timeDateField.setDate(now);
    bothDateField.setDate(now);
  }
  public void startApp() {
    Form aForm = new Form("DateField");
    aForm.append(dateDateField);
    aForm.append(timeDateField);
    aForm.append(bothDateField);
    aForm.addCommand(exitCommand);
    aForm.setCommandListener(this);
    display.setCurrent(aForm);
  }
  public void pauseApp() {
  }
  public void destroyApp(boolean unconditional) {
  }
  public void commandAction(Command c, Displayable s) {
    if (c == exitCommand) {
      destroyApp(false);
      notifyDestroyed();
    }
  }
}