Example usage for org.joda.time LocalDate getValue

List of usage examples for org.joda.time LocalDate getValue

Introduction

In this page you can find the example usage for org.joda.time LocalDate getValue.

Prototype

public int getValue(int index) 

Source Link

Document

Gets the value of the field at the specified index.

Usage

From source file:tw.com.softleader.sportslottery.setting.web.UserAction.java

public void iValidate(int select) {
    getFieldErrors().clear();// w w w.ja  v  a  2 s  .co  m
    if (model != null) {
        switch (select) {
        case 1:
            log.debug("iValidate...(...");
            if (model.getUserAccount() != null && model.getUserAccount().matches("^[a-zA-Z0-9]\\S{5,}$")) {
                this.check();
            } else {
                this.addFieldError("username", this.getText("invalid.fieldvalue.id"));
                log.debug("?" + model.getUserAccount());
            }
            if (userPassword == null || userPassword.length() < 5 || !userPassword.matches(".*[0-9].*")
                    || !userPassword.matches(".*[A-Za-z].*") || !userPassword.matches("^[a-zA-Z0-9]+$")) {
                this.addFieldError("password", this.getText("invalid.fieldvalue.password"));
                log.debug("?" + userPassword);
            }
            if (confirm_password == null || !confirm_password.equals(userPassword)) {
                this.addFieldError("confirm_password", this.getText("invalid.fieldvalue.confirm_password"));
                log.debug("??" + confirm_password + ":" + userPassword);
            }
            if (model.getUserBirthday() != null) {
                try {
                    LocalDate checkDate = new LocalDate();
                    if ((checkDate.getValue(0) - model.getUserBirthday().getValue(0)) < 18
                            || ((checkDate.getValue(0) - model.getUserBirthday().getValue(0)) == 18
                                    && (model.getUserBirthday().getValue(1) - checkDate.getValue(1)) > 0)
                            || ((checkDate.getValue(0) - model.getUserBirthday().getValue(0)) == 18
                                    && (model.getUserBirthday().getValue(1) - checkDate.getValue(1)) == 0
                                    && (model.getUserBirthday().getValue(2) - checkDate.getValue(2) > 0))) {
                        addFieldError("userBirth", this.getText("invalid.fieldvalue.birth"));
                        log.debug(checkDate + "?" + model.getUserBirthday());
                    }
                } catch (Exception e) {
                    addFieldError("userBirth", this.getText("invalid.fieldvalue.birth"));
                    log.debug("??");
                }
            }
            if (model.getUserEmail() != null && model.getUserEmail()
                    .matches("^[_a-z0-9-]+([.][_a-z0-9-]+)*@[a-z0-9-]+([.][a-z0-9-]+)*$")) {
                this.checkEmail().equals("error");
            } else {
                addFieldError("mail", "mail??");
                log.debug("Email???");
            }
            if (model.getUserName() == null || !model.getUserName().matches("^[\\u4E00-\\u9FA5]+$")) {
                addFieldError("name", this.getText("invalid.fieldvalue.name"));
                log.debug("???" + model.getUserName());
            }
            if (model.getUserCardId() != null && isValidTWPID(model.getUserCardId())) {
                this.checkUserCardId();
            } else {
                this.addFieldError("userCardId", this.getText("invalid.fieldvalue.cardid"));
                log.debug("?");
            }
            if (model.getUserPhone() != null && model.getUserPhone().length() < 14) {
                try {
                    Double userBank = Double.parseDouble(model.getUserPhone());
                } catch (NumberFormatException e) {
                    this.addFieldError("phone", this.getText("invalid.fieldvalue.bank"));
                    log.debug("?");
                }
            } else {
                this.addFieldError("phone", this.getText("invalid.fieldvalue.phone"));
                log.debug("???");
            }
            if (model.getUserBankAccount() != null
                    && model.getUserBankAccount().replaceAll("-", "").length() == 14
                    && !model.getUserBankAccount().matches(".*[eE].*")) {
                String temp = model.getUserBankAccount().replaceAll("-", "");
                try {
                    Double userBank = Double.parseDouble(temp);
                } catch (NumberFormatException e) {
                    this.addFieldError("userBankAccount", this.getText("invalid.fieldvalue.bank"));
                    log.debug("?");
                }
            } else {
                this.addFieldError("userBankAccount", this.getText("invalid.fieldvalue.bank"));
                log.debug("??" + model.getUserBankAccount());
            }
            break;
        case 2:
            log.debug("iValidate...(2");
            break;
        default:
            break;
        }
    }
}