×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    Question DateField and minutes 00

    Hi,

    I have a problem with minutes returned by DateField if "00", instead of 00 last minutes are returned.

    Details to reproduce:

    - form with:
    - DateField with inputMode DATE_TIME
    - StringField
    - command OK
    - in commandAction for OK:
    Calendar c = Calendar.getInstance();
    c.setTime(date);
    String time;
    time = new Integer(c.get(Calendar.HOUR)).toString() + ":" +
    new Integer(c.get(Calendar.MINUTE)).toString();
    stringItem1.setText(time);
    - run the midlet
    - set time to 11:50
    - press OK (stringField is set 11:50)
    - set time to 10:00
    - press OK (stringField is set 10:50)

    I can't understand why, can you help me?

    Thanks
    sambarza

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: DateField and minutes 00

    hi sambarza,

    are you sure about that?
    have you tested on emulator (which one) or one real device?
    at least on S60 3rd ed emulator it works as expected,

    regards,
    Peter

  3. #3
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: DateField and minutes 00

    Which device have you tried this on?

    Hartti

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    Re: DateField and minutes 00

    Thanks for you interest and sorry for the delay... holidays...

    I'm using real 6280 and Series 40 Platform SDK emulator, always the same problem

    Thanks
    Sambarza

  5. #5
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: DateField and minutes 00

    hi all,

    I was able to recreate that using s40 3rd Ed FP1 SDK/emulator:

    used code:
    Code:
    package tests;
    
    import java.util.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    
    public class TestMidlet extends MIDlet implements CommandListener, ItemStateListener{
        public void startApp() {
            if(form == null){
                form = new MyForm();
                form.addCommand(new Command("Quit", Command.EXIT, 1));
                form.setCommandListener(this);
                form.setItemStateListener(this);
                inputField = new DateField("Enter date", DateField.DATE_TIME);
                inputField.setDate(new Date());
                form.append(inputField);
                labelField = new StringItem("date test:", "");
                form.append(labelField);
            }
            Display.getDisplay(this).setCurrent(form);
        }
        
        public void pauseApp() {
        }
        
        public void destroyApp(boolean unconditional) {
        }
        //
        
        public void commandAction(Command command, Displayable displayable) {
            if(command.getCommandType() == Command.EXIT){
                Display.getDisplay(this).setCurrent(null);
                destroyApp(false);
                notifyDestroyed();
            }
        }
        
        public void itemStateChanged(Item item) {
            if(item == inputField){
                Calendar c = Calendar.getInstance();
                c.setTime(inputField.getDate());
                StringBuffer sb = new StringBuffer();
                sb.append("time: ");
                // append in ## (24-hour clock format values)
                sb.append(c.get(Calendar.HOUR_OF_DAY));
                sb.append(":");
                sb.append(c.get(Calendar.MINUTE));
                labelField.setText(sb.toString());
                sb = null;
            }
        }
        
        private MyForm form;
        private DateField inputField;
        private StringItem labelField;
        
        // Form
        class MyForm extends Form{
            MyForm(){
                super("TestMidlet");
            }
        }
    }
    behavior:
    - if new value is entered for "hour" field as single digit ("5" or "3") item does not broadcast state changed
    - if new value is entered for "hour" field as two digits (say as "06") value is updated (state changed is broadcasted)

    @Hartti:
    try changing for example "11" hour (11am) to "6" (6 am), string item won't be updated,
    then try the same by enterig "06" instaed of 6 only digit,

    I don't have real device yet to test that "on-device",

    regards,
    Peter

  6. #6
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: DateField and minutes 00

    hi Sambarza,

    you need different implementation I think,
    above code works just fine in S60 3rd ED emulator,
    what is your implementation? have you used item state change listener as in code I've tried?

    it could be underlying os implementation issue (Symbian or Nokia depending on platform), there is a bunch of threads about ItemStateChanged listeners:
    http://discussion.forum.nokia.com/fo...archid=1454923

    regards,
    Peter

Similar Threads

  1. 6021 DateField data_memory
    By Jordi11 in forum Mobile Java General
    Replies: 0
    Last Post: 2006-04-03, 10:35
  2. DateField on Nokia 3220 (Series 40)
    By TheWheat in forum Mobile Java General
    Replies: 0
    Last Post: 2006-03-28, 21:42

Posting Permissions

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