import java.util.*; import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class DateAndTime extends MIDlet implements CommandListener{ Display disp; Date d; Calendar c = Calendar.getInstance(); String time; DateField currentDate; int index; Form form; Command start, exit; public DateAndTime(){ form = new Form("Дата и Время"); d = new Date(); start = new Command("СТАРТ", Command.SCREEN, 1); exit = new Command("ВЫХОД", Command.EXIT, 0); currentDate = new DateField("", DateField.DATE_TIME); currentDate.setDate(d); } public void startApp(){ form.append("ЗАДАТЬ ВРЕМЯ: "); index = form.append(currentDate); form.addCommand(start); form.addCommand(exit); form.setCommandListener(this); disp = Display.getDisplay(this); disp.setCurrent(form); } public void pauseApp(){} public void destroyApp(boolean u){} public void commandAction(Command cmd, Displayable s) { if(cmd == exit) { notifyDestroyed(); } else if(cmd == start) { d = new Date(); c.setTime(d); time = c.get(Calendar.HOUR_OF_DAY) + ":" +c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND); form.append("" + time); }} }