| Reply | « Previous Thread | Next Thread » |
|
Hello friends,
I want to know the current time(hh:mm:ss) of device by writing simple midlet. I dont know how to proceed. could you please tell me how to achieve this? |
| manojkumar.m |
| View Public Profile |
| Find all posts by manojkumar.m |
|
This code should work for you:
Code:
Date d = new Date(); Calendar c = Calendar.getInstance(); c.setTime(d); String time = c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND); Pit |
|
Hi jappit,
thanks for your reply, but when I executed the application as you suggestd, its working fine on emulator, but when istalled on Nokia E61i and Nokia 6300, it is not installing and showing an error message : application not compatible with this phone. my code is : public class DateAndTime extends MIDlet implements CommandListener { Display disp; Form form = new Form("Data and Time"); Command start = new Command("start", Command.SCREEN, 1); Command exit = new Command("Exit", Command.EXIT, 0); Date d ; Calendar c = Calendar.getInstance(); String time; public void startApp() { form.append("TIME IS : "); form.addCommand(start); form.addCommand(exit); form.setCommandListener(this); disp = Display.getDisplay(this); disp.setCurrent(form); } public void pauseApp() { } public void destroyApp(boolean uncond) { } 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); form.append("\n"); } } } what is the problem? |
| manojkumar.m |
| View Public Profile |
| Find all posts by manojkumar.m |
|
Which CLDC and MIDP versions are you using? Also, are you using any non-standard APIs (even if it seems you're not from your code)?
Pit |
|
CLDC 1.1 and MIDP 2.1
I am using only standard APIs. |
| manojkumar.m |
| View Public Profile |
| Find all posts by manojkumar.m |
|
Both Nokia E61i and 6300 support MIDP 2.0, not MIDP 2.1, so you should change that setting. To be sure about phone specifications and supported APIs, always check here:
http://www.forum.nokia.com/devices/matrix_all_1.html Pit |
|
Though I changed the emulator settings to MIDP 2.0, it still shows the same error message.
|
| manojkumar.m |
| View Public Profile |
| Find all posts by manojkumar.m |
|
Thankyou jappit,
now i changed the emulator settings as suggested you. now it is installed on my devices. once again thanks for quick response. |
| manojkumar.m |
| View Public Profile |
| Find all posts by manojkumar.m |
|
One more doubt, when I started the midlet on my mobile, the current time is 15:59:1.
and the midlet shows the current time as 15:29:01. I dont know why there is a difference of 30 minutes. what might be the problem? any suggestions? |
| manojkumar.m |
| View Public Profile |
| Find all posts by manojkumar.m |
|
Mumble... do both phones give you the wrong time? Or one only (which one)?
|
|
|
|
Thank you very much Hartti for your quick response.
|
| manojkumar.m |
| View Public Profile |
| Find all posts by manojkumar.m |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| How to install a self-signed J2ME application in a mobile device? | shreyasbellary | Mobile Java Networking & Messaging & Security | 17 | 2009-04-30 20:44 |
| 6230, I close the connector next time midlet is started device not found anymore | olepogam | Bluetooth Technology | 3 | 2006-10-03 22:54 |
| J2ME Polish Version 1.0 | enough | Mobile Java General | 0 | 2004-07-27 02:10 |
| Can J2ME access the images that save on the device | binhtt | Mobile Java General | 1 | 2004-03-09 22:00 |