Date Manipulations

Hello Mobile Community,

Problem:

We are trying to do some date manipulation activities and we are unable to reference the java.text.SimpleDateFormat classes to get the date manipulations going. Because of this any device specific build fails.

Observation:

In the %MOBILE_DESIGNER%\Devices<DeviceType><Device Model>.xml there is a specific reference to a variable called cldc11 which points to the mobile designer specific data types.

Workaround:

· This above also is the name of a zip file in the Stubs directory of the installation and has certain specific java related code.

· To overcome the build issue, I have taken the java rt.jar and merged the contents of cldc11.zip into rt.jar and renamed the resulting file to cldc11.zip. The resulting file when included into the project, the build finishes successfully.

Question:

· Is this the correct way or is there a better way of doing this?

· Why does cldc11.zip contain and can someone explain its significance (especially since it contains some java library code)

_______________________________________________________

Best regards,

Krishnamoorthi.

Hi Krishnamoorthi,

No, I wouldn’t strongly advise against changing any of the install/build files that come with Mobile Designer. Your workaround suggested below will not fix the problem. Essentially, the Stubs are simply that - reference libs there as a list of what libraries, classes and methods have been implemented across the various target platforms (Android, iOS, BlackBerry, Windows Phone, etc.). If you change these Stub ZIPs it will not help your project at all as the supplied iOS, Windows Phone, etc. libraries will not contain equivalents of what you are adding.

What kind of date formatting are you trying to accomplish. CLDC already includes regular java.util.Calendar and Date classes, returning either string or primitive representations of the internal data - I’ve not come across a scenario where I couldn’t construct my required displayed date format through these.

Regards,

Nick.

Hi Krishnamoorthi,

CLDC 1.1 is the Connected Limited Device Configuration for mobile devices, as defined by JSR 139. Part of the definition includes limiting the library size and, hence, the available functionality, so you will see it has a fairly limited subset of the J2SE classes/data types you might be used to. By merging rt.jar with the cldc contents you are basically just adding to the classpath/stubs used for building your project and I don’t believe it will work for an actual device build except for, possibly, a few cases with Android builds.

For date manipulation, I recommend that you look at the java.util.Calendar and java.util.Date classes, as part of the midp spec. http://docs.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/index.html has the javadocs for midp 2.0.

Spencer