jMobileCore toolkit

com.jmobilecore.ui
Class DateField

java.lang.Object
  extended by com.jmobilecore.ui.core.Component
      extended by com.jmobilecore.ui.core.TextComponent
          extended by com.jmobilecore.ui.core.TextField
              extended by com.jmobilecore.ui.DateField

public class DateField
extends TextField

This class displays formatted textfield for entering date information Format of the date is specified by user. Blocks of digits are separated by divider.

Author:
Igor Shevlyakov - initial implementation, Greg Gridin - redesign

Field Summary
protected  int day
           
protected static int[] days
           
static byte DD_MM_YYYY
          Date format, example: 26/03/2004.
 char divider
          The divider for date formatting
static byte MM_DD_YYYY
          Date format, example: 03/26/2004.
protected  int month
           
protected  byte STYLE
          The current DateField formatting style.
protected  int year
           
static byte YYYY_MM_DD
          Date format, example: 2004:03:26.
 
Fields inherited from class com.jmobilecore.ui.core.TextField
adjustment, calculatedCaretPosition, calculatedCursorOffset, composer, currentLength, DEFAULT_SIZE, echoChar, HOFFSET, SCROLLABLE, VOFFSET
 
Fields inherited from class com.jmobilecore.ui.core.TextComponent
ALL_SPEC_CHARS, BORDER_GAP, BORDER_WIDTH, C_ALL_SPEC_CHARS, C_ALPHA, C_ALPHA_NUMERIC, C_ANY, C_EMAIL, C_EMAIL_SPEC_CHARS, C_LOWER_CASE, C_NO_CHARS, C_NUMERIC, C_SPACE, C_UPPER_CASE, cHandler, CHAR_OPTIONS, charOptionCounter, constraint, CURSOR_DELAY, CURSOR_TYPE_LINE, CURSOR_TYPE_SYMBOL, editable, EMAIL_SPEC_CHARS, insertMode, KEY_OPTIONS, lastKeyCode, LC_CHARS, NUMERIC_CHARS, SPACE_CHARS, UC_CHARS, validChars
 
Fields inherited from class com.jmobilecore.ui.core.Component
alignment, background, CENTER, focusable, focusedBackground, focusedForeground, font, foreground, height, isCompletelyVisible, isFocused, isVisible, LEFT, parentScreen, RIGHT, screenY, valid, width
 
Constructor Summary
DateField()
          Constructs a new DateField field.
DateField(byte style)
          Constructs a new DateField object of specified format.
DateField(byte style, char divider)
          Constructs a new DateField object of specified format.
DateField(byte style, char divider, java.util.Date date)
          Constructs a new DateField object of specified format with the specified value.
 
Method Summary
protected  void getBlocks()
          Sets day, month, year variables If the field contains invalid value, the method sets variable year to -1
 java.util.Date getDate()
          Returns the date value that is presented by this component.
 java.lang.String getFormattedText()
          Get formatted representation of Ipv4Field value or null if IPv4Field object value is set to null or incomplete
protected  char[] getFormattedText(boolean calcCursorOffset)
           
 byte getStyle()
           
protected  CustomFieldComposer initComposer()
          Initialize date field composer
 boolean isValid()
          Tests date field value for correctness
 void setDate(java.util.Date date)
          Sets date that is presented by this date component to be the specified value.
 void setStyle(byte newStyle)
           
 void setStyle(byte newStyle, char divider)
           
 void setStyle(byte newStyle, char divider, java.util.Date newDate)
           
 
Methods inherited from class com.jmobilecore.ui.core.TextField
adjust, destructor, getComposer, getCursorOffset, getText, init, keyPressed, paint, paintCursor, setHeight, setText
 
Methods inherited from class com.jmobilecore.ui.core.TextComponent
addValidChars, getCaretPosition, getKeyOption, initCursor, isCharValid, preProcessKeyCode, processKeyCode, resetCursor, resetCursorHandler, setCaretPosition
 
Methods inherited from class com.jmobilecore.ui.core.Component
getBackground, getFont, getForeground, getHeight, getWidth, invalidate, isFocusOwner, keyReleased, keyRepeated, paintBackground, pointerDragged, pointerPressed, pointerReleased, prepareForeground, releaseFocus, requestFocus, setFont
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

day

protected int day

days

protected static final int[] days

DD_MM_YYYY

public static final byte DD_MM_YYYY
Date format, example: 26/03/2004.

See Also:
Constant Field Values

divider

public char divider
The divider for date formatting


MM_DD_YYYY

public static final byte MM_DD_YYYY
Date format, example: 03/26/2004.

See Also:
Constant Field Values

month

protected int month

STYLE

protected byte STYLE
The current DateField formatting style.


year

protected int year

YYYY_MM_DD

public static final byte YYYY_MM_DD
Date format, example: 2004:03:26.

See Also:
Constant Field Values
Constructor Detail

DateField

public DateField()
Constructs a new DateField field.


DateField

public DateField(byte style)
Constructs a new DateField object of specified format.

Parameters:
style - the date format

DateField

public DateField(byte style,
                 char divider)
Constructs a new DateField object of specified format.

Parameters:
style - the date format
divider - the divider for the date field

DateField

public DateField(byte style,
                 char divider,
                 java.util.Date date)
Constructs a new DateField object of specified format with the specified value.

Parameters:
style - the date format
divider - the divider for the date field
date - the date value
See Also:
setStyle(byte)
Method Detail

getBlocks

protected void getBlocks()
Sets day, month, year variables If the field contains invalid value, the method sets variable year to -1


getDate

public java.util.Date getDate()
Returns the date value that is presented by this component. Time portion of returned Date value is set to 0 (hours, minutes, seconds)

Returns:
the Date representing the specified date

getFormattedText

public java.lang.String getFormattedText()
Get formatted representation of Ipv4Field value or null if IPv4Field object value is set to null or incomplete

Returns:
the String representing bank card number

getFormattedText

protected char[] getFormattedText(boolean calcCursorOffset)
Overrides:
getFormattedText in class TextField

getStyle

public byte getStyle()

initComposer

protected CustomFieldComposer initComposer()
Initialize date field composer

Returns:
CustomFieldComposer for date field

isValid

public boolean isValid()
Tests date field value for correctness

Returns:
true if the date field is valid false otherwise

setDate

public void setDate(java.util.Date date)
Sets date that is presented by this date component to be the specified value. Time portion of date argument is ignored

Parameters:
date - the date value

setStyle

public void setStyle(byte newStyle)

setStyle

public void setStyle(byte newStyle,
                     char divider)

setStyle

public void setStyle(byte newStyle,
                     char divider,
                     java.util.Date newDate)

jMobileCore toolkit