×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    94

    Unhappy How to open calendar in J2me?

    Hi to all,

    I have to open a calendar in midlet & select date from there?
    when I use calendar class then there is two forward slash "//" appears in my date filed and when I press any key then automatically date is shown in text box but calendar is not open.
    Can anyone tell me how could I open calendar in midlet?

    Thanks.
    Regards,
    Juned Ahmed

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: How to open calendar in J2me?

    Quote Originally Posted by junedahmed View Post
    Hi to all,

    I have to open a calendar in midlet & select date from there?
    when I use calendar class then there is two forward slash "//" appears in my date filed and when I press any key then automatically date is shown in text box but calendar is not open.
    Can anyone tell me how could I open calendar in midlet?

    Thanks.
    Try this code from FN Wiki- http://wiki.forum.nokia.com/index.ph...ar/date_picker
    Thanks,
    Ekta

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    94

    Re: How to open calendar in J2me?

    Hi , I am trying the same code but I have received an error when I run on WTK :
    cannot find symbol
    symbol : method ceil(double)
    location: class java.lang.Math
    this.weeks = (int)Math.ceil(((double)getStartWeekday() + getMonthDays()) / 7);

    nconvertible types
    found : java.lang.Math.ceil
    required: int
    this.weeks = (int)Math.ceil(((double)getStartWeekday() + getMonthDays()) / 7);

    when i run same peace of code on Eclipse then app run fine, but when i try to install on phone it throws an error "Invalid jar file".

    Any idea?

    Thanks.
    Regards,
    Juned Ahmed

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    94

    Re: How to open calendar in J2me?

    Thanks,




    now its working fine.
    Regards,
    Juned Ahmed

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    94

    Re: How to open calendar in J2me?

    Thanks,



    now its working fine.
    Regards,
    Juned Ahmed

  6. #6
    Regular Contributor
    Join Date
    Aug 2010
    Location
    Chennai, India.
    Posts
    176

    Re: How to open calendar in J2me?

    I'm also facing the same problem, want to open a calendar in form & select date in textField

    Calendar calendar=Calendar.getInstance();
    String time = Integer.toString(calendar.get(Calendar.DAY_OF_MONTH))+":"+Integer.toString(calendar.get(Calendar.MONTH)) + ":" + Integer.toString(calendar.get(Calendar.YEAR));
    static TextField txtDate = new TextField("Date :", time,15, TextField.ANY);

    Its show the current date not a calendar to select the date?
    How can i do this?

    help me
    kumar

  7. #7
    Regular Contributor
    Join Date
    Nov 2010
    Location
    Egypt,Mansoura
    Posts
    80

    Re: How to open calendar in J2me?

    Quote Originally Posted by kumar1234567 View Post
    I'm also facing the same problem, want to open a calendar in form & select date in textField

    Calendar calendar=Calendar.getInstance();
    String time = Integer.toString(calendar.get(Calendar.DAY_OF_MONTH))+":"+Integer.toString(calendar.get(Calendar.MONTH)) + ":" + Integer.toString(calendar.get(Calendar.YEAR));
    static TextField txtDate = new TextField("Date :", time,15, TextField.ANY);

    Its show the current date not a calendar to select the date?
    How can i do this?

    help me
    kumar
    You can use DateField instead of TextField Like that
    Code:
       // in the constructor
    
       private DateField dateField;
    
       // when u want it to appear
      Calendar calendar=Calendar.getInstance();
      dateField=new DateField("Date:",DateField.DATE);
    
      // this to appeand it in a form called form
    
      form.append(dateField);
     dateField.setDate(calendar.getTime());
     // and if u wanna to get the selected date
    
     Date d=dateField.getDate();
    
     // and u can change it to String as u want to display it or save it in database or ... etc
    i hope it work fine with u

    inform me if not

    Buffon
    Let The Impossible Happen!!!

  8. #8
    Regular Contributor
    Join Date
    Aug 2010
    Location
    Chennai, India.
    Posts
    176

    Re: How to open calendar in J2me?

    Thanks Buffon.,

    When i'm using DateField instead of TextField, I got calendar and select the date and setDate in DateField, Its all working in emulator.
    But i installed in my phone, Its simply showing ' // ' .

    Calendar calendar=Calendar.getInstance();
    dateField=new DateField("Date:",DateField.DATE);
    form.append(dateField);
    Its shows ' // ' .

    dateField.setDate(calendar.getTime());
    Its displaying current date as dateFormat mm/dd/yyyy in DateField.

    I want to open calendar and select a date and save it as i got in my emulator. I'm using Nokia 5230 s60 5th edition device.
    How can i do this?

    Thanks
    kumar

  9. #9
    Regular Contributor
    Join Date
    Nov 2010
    Location
    Egypt,Mansoura
    Posts
    80

    Re: How to open calendar in J2me?

    i tried it On Nokia SDK series 40 5 th Editon and it work it give me the current date but there was a command called set i pressed it and the calendar appear and i choose the date from it

    http://img42.imageshack.us/img42/8099/96097627.png

    i tried that exactly

    Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    
    import java.util.Calendar;
    import java.util.Date;
    import javax.microedition.lcdui.DateField;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.*;
    
    /**
     * @author Buffon
     */
    public class Data extends MIDlet {
        private DateField dateField;
        private Form form;
        public Data(){
            form = new Form("");
            Calendar calendar=Calendar.getInstance();
            dateField=new DateField("Date:",DateField.DATE);
            form.append(dateField);
            dateField.setDate(calendar.getTime());
            Date d=dateField.getDate();
    
    
        }
        public void startApp() {
            Display.getDisplay(this).setCurrent(form);
        }
    
        public void pauseApp() {
        }
    
        public void destroyApp(boolean unconditional) {
        }
    }
    inform me if there's no Set Command add automatically to Date Field

    hope it work with u

    Buffon
    Last edited by buffon2009; 2011-01-08 at 08:45. Reason: add the code
    Let The Impossible Happen!!!

  10. #10
    Regular Contributor
    Join Date
    Aug 2010
    Location
    Chennai, India.
    Posts
    176

    Re: How to open calendar in J2me?

    Thanks..,

    This s the same code i exactly used.

    Calendar calendar=Calendar.getInstance();
    dateField=new DateField("Date:",DateField.DATE);
    form.append(dateField);
    dateField.setDate(calendar.getTime())
    Date d=dateField.getDate();
    There is no Set Command in Date Field in my nokia device., displaying '//'.

Similar Threads

  1. how to open calendar in month view
    By manmay.gupta in forum Symbian
    Replies: 2
    Last Post: 2010-03-11, 04:35
  2. Replies: 4
    Last Post: 2010-03-08, 20:34
  3. How to open calendar on a specific day?
    By benzman81 in forum Symbian
    Replies: 0
    Last Post: 2009-08-11, 17:48
  4. Calendar with J2ME
    By chia_84 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2008-06-16, 08:36
  5. Calendar with J2ME
    By chia_84 in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2008-05-27, 14:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×