2
votes

I have loaded the calendar in my LWUIT based UI. Thanks to this thread. It is neat.

  1. when i select a certain date i want the calendar to close and the selected date to appear in my original form in dd-mmm-yyyy form.

  2. I want to take this selected date, set the clock to 1200 hrs (afternoon) on that day and find the time in milliseconds elapsed between now and 1200 hrs on the selected date. something i have earlier asked here but for a desktop java applications using netbeans 7.1.2.

I find that methods like getInstance, getCalendar, setTime, are not supported in the LWUIT calendar. Are they? I can only have date = getDate(); but cant set the clock on that date.

Further, 1. How to select current time (now) in milliseconds. Will this work?

`Calendar today = Calendar.getInstance();

Date time_now = today.getTime();`

  1. If it will, How do i find the difference between the date selected by user and time_now. (supposing that i simply add (12*60*60*1000) to the above difference to compensate for inability to set the clock to mid-day.) The real problem is that, above two objects are date objects and i want the difference in milliseconds as a double or long variable.

Whats the solution. Thanks in advance.

1
Anybody on LWUIT here. pl respond. thanks.Rajesh Acharya

1 Answers

2
votes

You are confusing the LWUIT com.sun.lwuit.Calendar class and the java.util.Calendar class, they have similar names but they are quite different. You can just use the java.util.Calendar class by typing in its fully qualified name.

Keep in mind that the java.util.Calendar class in J2ME is more limited than the one in Java SE but can still be used to some degree.