Alternative to Jformattedtextfield

17 views
Skip to first unread message

shop.servic...@gmail.com

unread,
Jul 5, 2017, 3:13:12 PM7/5/17
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA NetBeans 8.2
Desktop OS Windows 10
Simulator 3.7
Device Samsung SCH-1545 Android V 5.0.1

I have a requirement to provide a user to enter data in a MM/YY format. 

Tried using Picker, however it is producing false results as I like it opens a spinner dialog with 3 fields (3 char Month) Day of Month and 4 digit year.
prod_dateText = new Picker();
prod_dateText.setDate(inc.getDateObjectFromMMslashYY(prod_date));
SimpleDateFormat formatter1 = new SimpleDateFormat("MM/yy");
prod_dateText.setFormatter(formatter1);

When querying the Picker with prod_dateText.getDate()
It produced the expected date, however the resultingformat in the prod_dateText field is something like 33/17 when 02/17 was set.

Thoughts?

Shai Almog

unread,
Jul 6, 2017, 1:09:01 AM7/6/17
to CodenameOne Discussions, shop.servic...@gmail.com
Picker looks different on the device as it's implemented natively.
You can use this trick for masking: http://www.codenameone.com/blog/validation-regex-masking.html
This will use two separate fields. You can set constraint to numeric on the field and add validation to prevent invalid input.

We can't do the full masking support since input is native
Reply all
Reply to author
Forward
0 new messages