1 Attachment(s)
probleam in getting phone time and date !!!
Hi , i want to get phone current time and date . i use this code , but time is not true !!! please help me , where in this code is wrong ???
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
/**
* @author mahdi
*/
public class Midlet extends MIDlet {
Display display;
Form form = new Form("Clock");
Calendar calendar;
public void startApp() {
display = Display.getDisplay(this);
calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GTM"));
form.append(" Year : " + String.valueOf(calendar.get(Calendar.YEAR )) + "\n" );
form.append(" Month : " + String.valueOf(calendar.get(Calendar.MONTH)) + "\n");
form.append(" Day : " + String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)) + "\n");
form.append(" Hour : " + String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)) + "\n");
form.append(" Minute : " + String.valueOf(calendar.get(Calendar.MINUTE)) + "\n");
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}