how to set null date

18 views
Skip to first unread message

howud...@gmail.com

unread,
Sep 20, 2016, 11:09:11 AM9/20/16
to CodenameOne Discussions
for the date picker, I dont want it to be today's date.  I want it to be "...", or empty

 if (client.getDC_Date() != null) cmbDate1.setDate(client.getDC_Date());
 cmbDate2
.setDate(client.getDC_Date2());


if I dont call setDate, the picker defaults to today's date, and there is no way to leave the field blank if needed
if I call setDate(null) then when the picker is selected it get's a nullpointerexception

java.lang.NullPointerException
 at java
.util.Calendar.setTime(Calendar.java:1770)
 at com
.codename1.ui.spinner.Picker$1.actionPerformed(Picker.java:108)
 at com
.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349)
 at com
.codename1.ui.Button.fireActionEvent(Button.java:411)
 at com
.codename1.ui.Button.released(Button.java:442)
 at com
.codename1.ui.Button.pointerReleased(Button.java:530)
 at com
.codename1.ui.Form.pointerReleased(Form.java:2623)
 at com
.codename1.ui.Form.pointerReleased(Form.java:2559)
 at com
.codename1.ui.Component.pointerReleased(Component.java:3226)
 at com
.codename1.ui.Display.handleEvent(Display.java:2022)
 at com
.codename1.ui.Display.edtLoopImpl(Display.java:1067)
 at com
.codename1.ui.Display.mainEDTLoop(Display.java:996)
 at com
.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
 at com
.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)



Shai Almog

unread,
Sep 21, 2016, 12:46:38 AM9/21/16
to CodenameOne Discussions, howud...@gmail.com
Thanks, we'll fix that for the next update.

howud...@gmail.com

unread,
May 24, 2017, 9:43:26 PM5/24/17
to CodenameOne Discussions, howud...@gmail.com
I'm curious if this has been fixed?  If I setDate(null) on the simulator it's ok, on iOS it gives a null pointer exception.

Shai Almog

unread,
May 25, 2017, 1:11:34 AM5/25/17
to CodenameOne Discussions, howud...@gmail.com
I'm guessing it was. Do you have a stack trace from iOS?

howud...@gmail.com

unread,
May 25, 2017, 9:18:26 AM5/25/17
to CodenameOne Discussions, howud...@gmail.com
I dont have a stacktrace on iOS, I dont have a clue how to get one as my primary development is android.  It is easy to reproduce and to me it appears that it was fixed on the sim, android but not iOS.  Here is a very simple test case that reproduces the problem every time:

public class FrmTestDate extends com.codename1.ui.Form {
protected Picker p2 = new Picker();

public FrmTestDate() {
initManualComponents();
}
    

protected void initManualComponents() {
setLayout(new BorderLayout());
p2.setType(Display.PICKER_TYPE_DATE);
p2.setDate(null);

add(BorderLayout.SOUTH, p2);
add(BorderLayout.CENTER, new Label("Test"));
}
    
}


Steve Hannah

unread,
May 25, 2017, 12:09:25 PM5/25/17
to codenameone...@googlegroups.com, Peter Carlson
This found a potential issue, and committed a fix for it here: https://github.com/codenameone/CodenameOne/commit/e1931684c82b7bb8d794cd43c0abd2c95cf6b5ac
This will be included in next server update.

Steve

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/575ed973-4fa7-42ac-8d06-c4f02ffdb8a6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Steve Hannah
Software Developer
Codename One
Reply all
Reply to author
Forward
0 new messages