亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? datefield.java

?? 開發j2me 手機程序必須的用到的。文件較小
?? JAVA
字號:
package com.jmobilecore.ui;

import com.jmobilecore.ui.core.TextField;
import com.jmobilecore.ui.core.TextComponent;

import java.util.Date;
import java.util.Calendar;

/**
 * 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
 * @author Greg Gridin - redesign
 */
public class DateField extends TextField {

// internal constants and variables
    static final protected int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    protected int day, month, year;

    /**
     * Date format, example: 2004:03:26.
     */
    public static final byte YYYY_MM_DD = 1;

    /**
     * Date format, example: 26/03/2004.
     */
    public static final byte DD_MM_YYYY = 2;

    /**
     * Date format, example: 03/26/2004.
     */
    public static final byte MM_DD_YYYY = 3;

    /**
     * The current DateField formatting style.
     */
    protected byte STYLE;

    /**
     * The divider for date formatting
     */
    public char divider = '/';

    /**
     * Constructs a new <code>DateField</code> field.
     */
    public DateField() {
        this(MM_DD_YYYY, '/', null);
    }

    /**
     * Constructs a new <code>DateField</code> object of specified format.
     *
     * @param style   the date format
     */
    public DateField(byte style) {
        this(style, '/', null);
    }

    /**
     * Constructs a new <code>DateField</code> object of specified format.
     *
     * @param style   the date format
     * @param divider the divider for the date field
     */
    public DateField(byte style, char divider) {
        this(style, divider, null);
    }

    /**
     * Constructs a new <code>DateField</code> object of specified format
     * with the specified value.
     *
     * @param style   the date format
     * @param divider the divider for the date field
     * @param date    the date value
     * @see #setStyle
     */
    public DateField(byte style, char divider, Date date) {
        super(-1, TextComponent.C_NUMERIC);
        setStyle(style, divider, date);
    }

    /**
     * Initialize date field composer
     *
     * @return <code>CustomFieldComposer</code> for date field
     */
    protected CustomFieldComposer initComposer() {

        DigitalBlockComposer[] textBlocks = new DigitalBlockComposer[3];
        textBlocks[0] = new DigitalBlockComposer(DigitalBlockComposer.FIXED_SIZE, 4, ' ', 1970, 2038);
        textBlocks[1] = new DigitalBlockComposer(DigitalBlockComposer.FIXED_SIZE, 2, ' ', 1, 12);
        textBlocks[2] = new DigitalBlockComposer(DigitalBlockComposer.FIXED_SIZE, 2, ' ', 1, 31);
        return new CustomFieldComposer(textBlocks) {
            public void setText(String text) {
            }

            public boolean caretLeft() {
                if (textBlocks[curBlock].caretLeft()) {
                    if (textBlocks[curBlock].getCaretPosition() >= 0) {
                        return true;
                    }
                }
                boolean isComplete = textBlocks[curBlock].isComplete();
                if (!isComplete) return true;
                return setCaretPosition(getCaretPosition()-1);
            }

            public boolean caretRight() {
                if (textBlocks[curBlock].caretRight()) {
                    if (textBlocks[curBlock].getCaretPosition() < textBlocks[curBlock].getMaxSize()) {
                        return true;
                    }
                }
                boolean isComplete = textBlocks[curBlock].isComplete();
                if (!isComplete) return true;
                return setCaretPosition(getCaretPosition());
            }

            public int getCaretPosition() {
                if (STYLE==YYYY_MM_DD) {
                    if (curBlock==0) return textBlocks[0].getCaretPosition();
                    if (curBlock==1) return textBlocks[1].getCaretPosition()+4;
                    if (curBlock==2) return textBlocks[2].getCaretPosition()+6;
                }
                if (STYLE==DD_MM_YYYY) {
                    if (curBlock==0) return textBlocks[0].getCaretPosition()+4;
                    if (curBlock==1) return textBlocks[1].getCaretPosition()+2;
                    if (curBlock==2) return textBlocks[2].getCaretPosition();
                }
                if (STYLE==MM_DD_YYYY) {
                    if (curBlock==0) return textBlocks[0].getCaretPosition()+4;
                    if (curBlock==1) return textBlocks[1].getCaretPosition();
                    if (curBlock==2) return textBlocks[2].getCaretPosition()+2;
                }
                return 0;
            }

            public boolean setCaretPosition(int caretPosition) {

                if (caretPosition<0 || caretPosition>8) {
                    return false;
                }
                if (STYLE==YYYY_MM_DD) {
                    if (caretPosition<4) { textBlocks[curBlock=0].setCaretPosition(caretPosition); }
                    else if (caretPosition<6) { textBlocks[curBlock=1].setCaretPosition(caretPosition-4); }
                    else textBlocks[curBlock=2].setCaretPosition(caretPosition-6);
                    return true;
                }
                if (STYLE==DD_MM_YYYY) {
                    if (caretPosition<2) textBlocks[curBlock=2].setCaretPosition(caretPosition);
                    else if (caretPosition<4) textBlocks[curBlock=1].setCaretPosition(caretPosition-2);
                    else textBlocks[curBlock=0].setCaretPosition(caretPosition-4);
                    return true;
                }
                if (STYLE==MM_DD_YYYY) {
                    if (caretPosition<2) textBlocks[curBlock=1].setCaretPosition(caretPosition);
                    else if (caretPosition<4) textBlocks[curBlock=2].setCaretPosition(caretPosition-2);
                    else textBlocks[curBlock=0].setCaretPosition(caretPosition-4);
                    return true;
                }
                return false;
            }
        };
    }

    /**
     * Sets <code>day, month, year</code> variables
     * If the field contains invalid value, the method sets
     * variable <code>year</code> to <code>-1</code>
     */
    protected void getBlocks() {
        day = month = year = 0;

        try {
            DigitalBlockComposer blocks[] = (DigitalBlockComposer[])((CustomFieldComposer) composer).textBlocks;
            year = (int) blocks[0].getValue();
            month = (int) blocks[1].getValue();
            day = (int) blocks[2].getValue();
        } catch (Exception e) {
            year = -1;
            return;
        }
    }

    protected char[] getFormattedText(boolean calcCursorOffset) {

        TextBlockComposer blocks[] = ((CustomFieldComposer) composer).textBlocks;
        currentLength = 10;
        char formattedText[] = new char[currentLength];
        int curBlock = ((CustomFieldComposer)composer).getCurrentBlock();
        int fmtCaretPos = 0;
        char [] yearText = blocks[0].getChars();
        char [] monthText = blocks[1].getChars();
        char [] dayText = blocks[2].getChars();
        int yearPos = blocks[0].getCaretPosition();
        int monthPos = blocks[1].getCaretPosition();
        int dayPos = blocks[2].getCaretPosition();

        if (STYLE==YYYY_MM_DD) {
            System.arraycopy(yearText, 0, formattedText, 0, 4);
            formattedText[4] = divider;
            System.arraycopy(monthText, 0, formattedText, 5, 2);
            formattedText[7] = divider;
            System.arraycopy(dayText, 0, formattedText, 8, 2);
            if (curBlock == 0) {
                fmtCaretPos = yearPos;
            }
            if (curBlock == 1) {
                fmtCaretPos = 5 + monthPos;
            }
            if (curBlock == 2) {
                fmtCaretPos = 8 + dayPos;
            }
        }
        if (STYLE==DD_MM_YYYY) {
            System.arraycopy(dayText, 0, formattedText, 0, 2);
            formattedText[2] = divider;
            System.arraycopy(monthText, 0, formattedText, 3, 2);
            formattedText[5] = divider;
            System.arraycopy(yearText, 0, formattedText, 6, 4);
            if (curBlock == 0) {
                fmtCaretPos = 6 + yearPos;
            }
            if (curBlock == 1) {
                fmtCaretPos = 3 + monthPos;
            }
            if (curBlock == 2) {
                fmtCaretPos = dayPos;
            }
        }
        if (STYLE==MM_DD_YYYY) {
            System.arraycopy(monthText, 0, formattedText, 0, 2);
            formattedText[2] = divider;
            System.arraycopy(dayText, 0, formattedText, 3, 2);
            formattedText[5] = divider;
            System.arraycopy(yearText, 0, formattedText, 6, 4);
            if (curBlock == 0) {
                fmtCaretPos = 6 + yearPos;
            }
            if (curBlock == 1) {
                fmtCaretPos = monthPos;
            }
            if (curBlock == 2) {
                fmtCaretPos = 3 + dayPos;
            }
        }

        if (calcCursorOffset) {
            calculatedCaretPosition = fmtCaretPos;
            calculatedCursorOffset = getCursorOffset(formattedText, calculatedCaretPosition);
        }
        return formattedText;
    }

    /**
     * Get formatted representation of <code>Ipv4Field</code> value
     * or <code>null</code> if <code>IPv4Field</code> object value is set to null or incomplete
     *
     * @return the <code>String</code> representing bank card number
     */
    public String getFormattedText() {
        if (isValid()) {
            return String.valueOf(getFormattedText(false));
        }
        return null;
    }

    public void setStyle(byte newStyle) {
        setStyle(newStyle, '/', null);
    }

    public void setStyle(byte newStyle, char divider) {

        setStyle(newStyle, divider, null);
    }

    public void setStyle(byte newStyle, char divider, Date newDate) {

        if (newStyle < 1 || newStyle > 3) return;
        Date date = newDate;
        if (date==null) date = getDate();
        STYLE = newStyle;
        this.divider = divider;
        if (composer != null) {
            composer.destructor();
        }
        composer = initComposer();
        setDate(date);
    }

    public byte getStyle() {

        return STYLE;
    }

    /**
     * Returns the date value that is presented by this component.
     * Time portion of returned <code>Date</code> value is set to 0 (hours,
     * minutes, seconds)
     *
     * @return the <code>Date</code> representing the specified date
     */
    public Date getDate() {
        if (!isValid()) {
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.DATE, day);
        cal.set(Calendar.MONTH, month - 1);
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }

    /**
     * Sets date that is presented by this date component to be the
     * specified value.
     * Time portion of <code>date</code> argument is ignored
     *
     * @param date the date value
     */
    public void setDate(Date date) {

        if (date == null) {
            ((CustomFieldComposer) composer).clear();
        } else {
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            day = cal.get(Calendar.DATE);
            month = cal.get(Calendar.MONTH) + 1;
            year = cal.get(Calendar.YEAR);
            cal = null;

            String dayStr = ((day < 10) ? "0" : "") + String.valueOf(day);
            String monthStr = ((month < 10) ? "0" : "") + String.valueOf(month);
            String yearStr = String.valueOf(year);
            DigitalBlockComposer blocks[] = (DigitalBlockComposer[])((CustomFieldComposer) composer).textBlocks;
            blocks[0].setText(yearStr);
            blocks[1].setText(monthStr);
            blocks[2].setText(dayStr);
        }
        setCaretPosition(0);
    }

    /**
     * This method should not be used for the class and intentionally set to deprecated
     * Use #getFormattedText() method instead.
     *
     * @deprecated
     */
    public String getText() {
        return null;
    }

    /**
     * This method should not be used for the class and intentionally set to
     * deprecated
     * Use #setDate(Date date) method instead.
     *
     * @deprecated
     */
    public void setText(String text) {
    }

    /**
     * Tests date field value for correctness
     *
     * @return <code>true</code> if the date field is valid
     *         <code>false</code> otherwise
     */
    public boolean isValid() {
        if (!((CustomFieldComposer) composer).isComplete()) return false;
        getBlocks();
        if (year <= 0) return false;
        days[1] = ((year % 4) == 0) ? 29 : 28;
        return day <= days[month - 1];
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕综合网| 国内外成人在线| 99久久伊人网影院| 久久中文字幕电影| 久久国产福利国产秒拍| 欧美男人的天堂一二区| 亚洲一区二区三区自拍| 欧美日韩一区二区在线观看| 1000精品久久久久久久久| 91首页免费视频| 亚洲欧美另类小说视频| 91在线免费视频观看| 亚洲一区二区在线免费观看视频 | 国产成人av电影在线播放| 久久久www免费人成精品| 国产精品538一区二区在线| 久久久高清一区二区三区| 国产高清一区日本| 中文字幕一区二区三区视频 | 丁香婷婷综合色啪| 亚洲色图欧美在线| 国产精品视频一二三| 亚洲福利视频一区二区| 欧美性xxxxx极品少妇| 国产综合久久久久久鬼色| 91精品国产91久久久久久最新毛片| 亚洲成av人片一区二区梦乃 | 99视频国产精品| 亚洲一区在线看| 日韩欧美中文字幕公布| 国产91丝袜在线播放0| 亚洲视频一区二区在线观看| 欧美日韩综合色| 极品美女销魂一区二区三区免费| 国产精品免费免费| 欧美欧美午夜aⅴ在线观看| 狠狠色综合色综合网络| 激情另类小说区图片区视频区| 国产高清在线精品| 亚洲免费成人av| 欧美mv和日韩mv国产网站| 成人av在线网| 日韩高清电影一区| 依依成人综合视频| 在线观看一区二区精品视频| 午夜精品成人在线视频| 久久精品无码一区二区三区| 在线观看欧美精品| 国产乱码精品一品二品| 亚洲国产日日夜夜| 国产视频一区二区在线观看| 精品视频在线免费观看| 久久99精品国产麻豆婷婷| 亚洲精品成人悠悠色影视| 久久久久国产精品厨房| 欧美唯美清纯偷拍| 粉嫩一区二区三区在线看| 日日夜夜免费精品视频| 国产精品日日摸夜夜摸av| 欧美一卡在线观看| 91丨国产丨九色丨pron| 国产最新精品免费| 亚洲成av人片一区二区| 国产精品每日更新在线播放网址| 日韩视频中午一区| 欧美性生活久久| 成人h版在线观看| 韩国精品在线观看| 蜜臀av性久久久久蜜臀aⅴ四虎| 亚洲欧美一区二区三区国产精品 | 欧美一区二区三区在线看| av一区二区不卡| 国产一二三精品| 蜜臀av在线播放一区二区三区| 亚洲美女淫视频| 中文字幕不卡在线| 国产香蕉久久精品综合网| 日韩视频一区二区| 这里只有精品免费| 欧美日本不卡视频| 91天堂素人约啪| caoporn国产一区二区| 国产一区二区免费视频| 美脚の诱脚舐め脚责91| 日韩av一区二区在线影视| 亚洲午夜国产一区99re久久| 一区二区三区中文在线观看| 国产精品理伦片| 中文字幕欧美区| 日本一区二区不卡视频| 国产日本欧洲亚洲| 国产精品污www在线观看| 久久久精品tv| 久久蜜桃av一区二区天堂| xnxx国产精品| 久久精品一级爱片| 久久久久久久性| 国产人成一区二区三区影院| 欧美国产日韩在线观看| 国产日韩精品一区二区三区| 中文字幕成人在线观看| 日本一区二区成人在线| 中文字幕一区av| 亚洲免费视频中文字幕| 亚洲人123区| 亚洲gay无套男同| 人人精品人人爱| 极品少妇一区二区三区精品视频| 精品在线免费视频| 粉嫩13p一区二区三区| 成人激情黄色小说| 欧美性大战xxxxx久久久| 8v天堂国产在线一区二区| 日韩一区二区三区视频| 久久婷婷一区二区三区| 亚洲欧洲日韩在线| 亚洲地区一二三色| 精品亚洲成a人在线观看| 国产不卡在线视频| 91丨九色丨国产丨porny| 欧美久久久久久久久久| 精品国产免费视频| 国产精品丝袜久久久久久app| 亚洲图片欧美激情| 日韩精品乱码免费| 国产精品中文有码| 欧美优质美女网站| 欧美精品一区二区三区四区| 久久精品综合网| 亚洲一区国产视频| 国产精品系列在线观看| 色成年激情久久综合| 日韩欧美一二三四区| 亚洲色图清纯唯美| 老司机精品视频一区二区三区| 国产91在线看| 欧美二区在线观看| 国产免费久久精品| 亚洲www啪成人一区二区麻豆| 国内精品伊人久久久久av影院| 不卡av免费在线观看| 欧美一级黄色录像| 亚洲日本在线天堂| 看电视剧不卡顿的网站| 99re热这里只有精品视频| 9191成人精品久久| 中文字幕在线一区免费| 青草av.久久免费一区| av高清不卡在线| 日韩一区二区精品葵司在线| 中文字幕一区二区三区不卡在线 | 亚洲成av人在线观看| 国产成人免费高清| 91精品国产欧美一区二区18| 日本美女一区二区三区视频| 丁香婷婷综合色啪| 精品久久久久av影院| 亚洲国产乱码最新视频| 成人精品国产一区二区4080| 日韩精品专区在线影院重磅| 一区二区在线观看不卡| 粉嫩在线一区二区三区视频| 日韩一级二级三级精品视频| 亚洲精品水蜜桃| 成人性视频网站| 精品国产a毛片| 日韩黄色免费电影| 在线亚洲一区二区| 中文字幕一区二区三区不卡| 激情综合色综合久久| 制服丝袜激情欧洲亚洲| 亚洲午夜激情网站| 色狠狠色狠狠综合| 亚洲欧美福利一区二区| 成人一级片网址| 久久久久久久国产精品影院| 青青草国产精品97视觉盛宴| 色天使色偷偷av一区二区| 国产精品白丝在线| 床上的激情91.| 亚洲国产成人自拍| 成人在线视频一区二区| 久久久久国产精品免费免费搜索| 免费成人结看片| 欧美精品日韩精品| 日韩精品成人一区二区三区| 欧美色图激情小说| 五月天亚洲精品| 欧美日韩一区 二区 三区 久久精品| 亚洲欧美日韩中文播放| 色综合久久综合| 中文字幕亚洲精品在线观看| 成人avav在线| 中文字幕av一区二区三区高| 高清久久久久久| 国产精品国产三级国产aⅴ入口 | jiyouzz国产精品久久| 亚洲国产精品二十页| 美女性感视频久久| 久久综合九色综合97婷婷女人 |