Time picker, how to set current time ?

30 views
Skip to first unread message

Gareth Murfin

unread,
Feb 15, 2018, 11:27:19 PM2/15/18
to CodenameOne Discussions
What is the easiest way to set a timer picker to use current time? 

this 

  Date now = new Date();
        timePicker.setDate(now);

causes:

 java.lang.ClassCastException - java.util.Date cannot be cast to java.lang.Integer

Shai Almog

unread,
Feb 16, 2018, 12:31:39 AM2/16/18
to CodenameOne Discussions
 setTime(timeInMins);

Gareth Murfin

unread,
Feb 16, 2018, 2:17:49 AM2/16/18
to CodenameOne Discussions
thanks shai, seems a strange call, so I have to manually work out how many minutes have passed since midnight?

On Friday, February 16, 2018 at 1:31:39 PM UTC+8, Shai Almog wrote:
 setTime(timeInMins);

Shai Almog

unread,
Feb 17, 2018, 12:01:40 AM2/17/18
to CodenameOne Discussions
Just get the hour from the Calendar class.

Gareth Murfin

unread,
Feb 18, 2018, 6:54:12 PM2/18/18
to CodenameOne Discussions
Will try thanks mate, funny thing is I alway go for your depreciated getHour() getDay() ones, they are so convnient but they will not compile. I suspect they are actually Sun's own depreciated methods, but I still wish they worked :) Keep up the good work my friend, cn1 really is feeling nice, I cannot say I like the new gui editor yet, but the old one is still serving me perfectly, I have very high hopes for the new one, but it was acting odd so Im waiting  a bit :)
Reply all
Reply to author
Forward
0 new messages