Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: how to get phone time and date

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default how to get phone time and date

    Hi , 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 ???
     
    /*
     * 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) {
        }
    }


  2. #2
    Junior Member
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: how to get phone time and date

    Hi , code is true , i test in my phone and it`s work currectly

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: how to get phone time and date

    Quote Originally Posted by mahdi View Post
    Hi , code is true , i test in my phone and it`s work currectly
    Hey mahdi. Welcome to the Java Programming Forums

    I'm glad this is working for you!!
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. hey - Mobile phone drinking game
    By pazzy in forum Java ME (Mobile Edition)
    Replies: 9
    Last Post: August 4th, 2009, 09:41 AM
  2. [SOLVED] How to start writing java mobile application?
    By Koâk in forum Java ME (Mobile Edition)
    Replies: 15
    Last Post: July 30th, 2009, 01:52 AM
  3. How to Get the current date and time
    By JavaPF in forum Java Programming Tutorials
    Replies: 2
    Last Post: December 2nd, 2008, 01:55 PM