mydatefield.java

来自「j2me简单实例,j2me教程加源码,希望大家喜欢」· Java 代码 · 共 46 行

JAVA
46
字号
package com.j2medev.httpme.view;

import java.util.Date;
import javax.microedition.lcdui.DateField;

/**
 * MyDateField is the subclass of javax.microedition.lcdui.DateField,it add a field name so that 
 * FormUtil can collect the data in MyDateField.you can get the date in String style by invoke getDateByString().
 *
 * @author mingjava
 * @version 0.1 05/06/2006
 * @since httpme 0.1
 */
public class MyDateField extends DateField {
    
    private String fieldName = "";
    /** Creates a new instance of MyDateField */
    public MyDateField(String _label,int _mode,String _fieldName) {
        super(_label,_mode);
        this.setFieldName(_fieldName);
    }
    /**
     * get the field name of MyDateField
     * @return a string the field name 
     */
    public String getFieldName() {
        return fieldName;
    }
    /**
     * set the field name of MyDateField
     * @param fieldName the field name
     *
     */
    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }
    
    /**
     * get the date from MyDateField
     * @return a string represent the date,in fact it's a String Wrapper of long value
     */
    public String getDateByString(){
        return String.valueOf(getDate().getTime());
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?