J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software

DateField

A datefield in action The DateField allows you to enter dates and time in different modes:

  • Native Input Mode: When the native mode is used, a new input screen will pop up for the user. This allows your user to use all native input mechanisms that the target device supports but it does interrupt the flow within the application. The Native Input Mode is used by default.
  • Direct Input Mode: With the Direct Input Mode J2ME Polish accepts input directly without showing a new popup screen.
    <variable name="polish.DateField.useDirectInput" value="true"/>
    

Design

The above DateField has been designed with following styles:

colors {
	fontColor: rgb( 30, 85, 86 );
}
.dateInput {
	margin: 1;
	padding: 4;
	font-style: bold;
	font-size: small;
	font-color: fontColor;
	background-color: silver;
	border-color: black;
}

.dateInput:hover {
	padding: 3;
	border-width: 2;
	background-color: white;
}

Additionally following settings have been made:

<variable name="polish.DateField.useDirectInput" value="true"/>

You can use following attributes for designing a DateField:

DateField-Commands

A DateField adds the "Clear" command to the menu when the direct input mode is used. The names of this and other commands can be changed easily using localization in your messages.txt file:

polish.command.clear=Reset

Programming

Use the DateField like the MIDP javax.microedition.lcdui.DateField:

//#style dateInput
this.birthdate = new DateField( "birthday:", DateField.DATE );
this.birthdate.setDate( new Date( System.currentTimeMillis() ) );

Please refer to the "datefield" sample application for a working example.

Configuration

There are several preprocessing variables that you can either specify in the <variables> section of your build.xml or in your messages.txt files when using the Localization framework.

Variable  DefaultExplanation
polish.DateFormat ymd The sequence of date parts - use y for the year, m for the month and d for the day. US American format is for example mdy.
You can also use the abbreviations us for US American, fr for French and de for German date formats.
For TIME or DATE_TIME DateFields hh:mm will be appended in any case.
polish.DateFormatEmptyText YYYY-MM-DD Defines the text that should be shown by an empty DateField - the shown default depends on the polish.DateFormat variable as well - if polish.DateFormat is for example mdy, the default will be MM-DD-YYYY.
polish.DateFormatSeparator - The separator between years, months and days of a DATE or DATE_TIME DateField.
polish.DateField.useDirectInputForPointer false Enables the usage of a CalendarItem when a DateField is clicked on a touch device. By default the native implementation is used.

JavaDoc

back to top