Example usage for org.joda.time LocalDate getYear

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

Introduction

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

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

From source file:org.mifos.ui.core.controller.FundTransferFormBean.java

License:Open Source License

public void setTrxnDate(LocalDate date) {
    if (date == null) {
        trxnDateDD = "";
        trxnDateMM = "";
        trxnDateYY = "";
    } else {/*  w  w  w.  j av  a  2  s.  c om*/
        trxnDateDD = String.valueOf(date.getDayOfMonth());
        trxnDateMM = String.valueOf(date.getMonthOfYear());
        trxnDateYY = String.valueOf(date.getYear());
    }
}

From source file:org.mifos.ui.core.controller.FundTransferFormBean.java

License:Open Source License

public void setReceiptDate(LocalDate date) {
    if (date == null) {
        receiptDateDD = "";
        receiptDateMM = "";
        receiptDateYY = "";
    } else {//  ww  w.  j  av a 2  s.  c o  m
        receiptDateDD = String.valueOf(date.getDayOfMonth());
        receiptDateMM = String.valueOf(date.getMonthOfYear());
        receiptDateYY = String.valueOf(date.getYear());
    }
}

From source file:org.mifos.ui.loan.controller.LoanRepaymentFormBean.java

License:Open Source License

public void setPaymentDate(LocalDate paymentDate) {
    paymentDateDD = paymentDate.getDayOfMonth();
    paymentDateMM = paymentDate.getMonthOfYear();
    paymentDateYY = paymentDate.getYear();
}

From source file:org.mifosplatform.portfolio.financialyear.command.FinancialYearCommand.java

License:Mozilla Public License

public void validateForCreate() {
    final List<ApiParameterError> dataValidationErrors = new ArrayList<>();

    final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
            .resource("financial.year");
    final LocalDate currentDate = new LocalDate();

    baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.START_YEAR.getValue())
            .value(this.startYear).notNull().ignoreIfNull().integerGreaterThanZero()
            .inMinMaxRange(currentDate.getYear() - 10, currentDate.getYear() + 1);
    baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.END_YEAR.getValue())
            .value(this.endYear).notNull().ignoreIfNull().integerGreaterThanZero()
            .inMinMaxRange(currentDate.getYear() - 10, currentDate.getYear() + 1);
    if (this.startYear != null && this.endYear != null) {
        baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.END_YEAR.getValue())
                .value(this.endYear).integerGreaterThanNumber(this.startYear);

        final LocalDate startDate = new LocalDate(this.startYear, 1, 1);
        final LocalDate endDate = new LocalDate(this.endYear, 12, 31);
        baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.START_DATE.getValue())
                .value(this.startDate).notNull().ignoreIfNull().validateDateBetween(startDate, endDate);
        baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.END_DATE.getValue())
                .value(this.endDate).notNull().ignoreIfNull().validateDateAfter(startDate)
                .validateDateBetween(startDate, endDate);
    }//from www. j a  va 2  s  .co  m
    baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.CURRENT.getValue()).value(this.current)
            .notNull().ignoreIfNull().validateForBooleanValue();
    baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.CLOSED.getValue()).value(this.closed)
            .notNull().ignoreIfNull().validateForBooleanValue();

    if (!dataValidationErrors.isEmpty()) {
        throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
                "Validation errors exist.", dataValidationErrors);
    }
}

From source file:org.mifosplatform.portfolio.financialyear.command.FinancialYearCommand.java

License:Mozilla Public License

public void validateForUpdate() {
    final List<ApiParameterError> dataValidationErrors = new ArrayList<>();

    final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
            .resource("financial.year");
    final LocalDate currentDate = new LocalDate();

    baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.START_YEAR.getValue())
            .value(this.startYear).notNull().ignoreIfNull().integerGreaterThanZero()
            .inMinMaxRange(currentDate.getYear() - 10, currentDate.getYear() + 1);
    baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.END_YEAR.getValue())
            .value(this.endYear).notNull().ignoreIfNull().integerGreaterThanZero()
            .inMinMaxRange(currentDate.getYear() - 10, currentDate.getYear() + 1);
    if (this.startYear != null && this.endYear != null) {
        baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.END_YEAR.getValue())
                .value(this.endYear).integerGreaterThanNumber(this.startYear);

        final LocalDate startDate = new LocalDate(this.startYear, 1, 1);
        final LocalDate endDate = new LocalDate(this.endYear, 12, 31);
        baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.START_DATE.getValue())
                .value(this.startDate).notNull().ignoreIfNull().validateDateBetween(startDate, endDate);
        baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.END_DATE.getValue())
                .value(this.endDate).notNull().ignoreIfNull().validateDateAfter(startDate)
                .validateDateBetween(startDate, endDate);
    }//from   w  ww.j a v  a2s . c  o m
    baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.CURRENT.getValue()).value(this.current)
            .notNull().ignoreIfNull().validateForBooleanValue();
    baseDataValidator.reset().parameter(FINANCIAL_YEAR_JSON_INPUT_PARAMS.CLOSED.getValue()).value(this.closed)
            .notNull().ignoreIfNull().validateForBooleanValue();

    if (!dataValidationErrors.isEmpty()) {
        throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
                "Validation errors exist.", dataValidationErrors);
    }
}

From source file:org.netxilia.api.utils.DateUtils.java

License:Open Source License

public static LocalDateTime toLocalDateTime(ReadablePartial partial, LocalDateTime fullDateTime) {
    if (partial instanceof LocalDateTime) {
        return (LocalDateTime) partial;
    }//from  w w w . jav  a  2  s  .com
    if (partial instanceof LocalDate) {
        LocalDate d = (LocalDate) partial;
        return new LocalDateTime(d.getYear(), d.getMonthOfYear(), d.getDayOfMonth(),
                fullDateTime.getHourOfDay(), fullDateTime.getMinuteOfHour(), fullDateTime.getSecondOfMinute(),
                fullDateTime.getMillisOfSecond());
    }

    if (partial instanceof LocalTime) {
        LocalTime t = (LocalTime) partial;
        return new LocalDateTime(fullDateTime.getYear(), fullDateTime.getMonthOfYear(),
                fullDateTime.getDayOfMonth(), t.getHourOfDay(), t.getMinuteOfHour(), t.getSecondOfMinute(),
                t.getMillisOfSecond());
    }

    throw new IllegalArgumentException("The partial parameter has an unsupported class:" + partial.getClass());
}

From source file:org.openmrs.module.referencedemodata.ReferenceDemoDataActivator.java

License:Open Source License

private Date randomBirthdate() {
    LocalDate now = LocalDate.now();
    LocalDate joda = new LocalDate(randomBetween(now.getYear() - MAX_AGE, now.getYear() - MIN_AGE),
            randomBetween(1, 12), randomBetween(1, 28));
    return joda.toDate();
}

From source file:org.pentaho.metadata.query.model.util.DataTypeDetector.java

License:Open Source License

public static Object getValue(String valueAsString) {
    if (valueAsString != null) {
        DataType type = getDataType(valueAsString);
        switch (type) {
        case STRING:
            return valueAsString;
        case BOOLEAN:
            return BooleanComparator.parseBoolean(valueAsString);
        case NUMERIC:
            return Integer.parseInt(valueAsString);
        // case DOUBLE:
        // return Double.parseDouble(valueAsString);
        case DATE:
            LocalDate localDate = new LocalDate(valueAsString);
            return new Date(new DateTime(localDate.getYear(), localDate.getMonthOfYear(),
                    localDate.getDayOfMonth(), 0, 0, 0, 0).getMillis());
        /*//from w  ww  . j av a  2  s. c om
         * case TIME: LocalTime localTime = new LocalTime(valueAsString); return new Time(new DateTime(1970, 1, 1,
         * localTime .getHourOfDay(), localTime.getMinuteOfHour(), localTime .getSecondOfMinute(),
         * localTime.getMillisOfSecond()) .getMillis());
         */
        default:
            throw new IllegalStateException(
                    Messages.getErrorString("DataTypeDetector.ERROR_0001_UNSUPPORTED_COLUMN_TYPE", type)); //$NON-NLS-1$
        }
    }
    return null;
}

From source file:org.springframework.ws.samples.airline.schema.support.SchemaConversionUtils.java

License:Apache License

public static XMLGregorianCalendar toXMLGregorianCalendar(LocalDate localDate)
        throws DatatypeConfigurationException {
    DatatypeFactory factory = DatatypeFactory.newInstance();
    return factory.newXMLGregorianCalendarDate(localDate.getYear(), localDate.getMonthOfYear(),
            localDate.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED);
}

From source file:org.springsource.restbucks.payment.CreditCard.java

License:Apache License

/**
 * Protected setter to allow binding the expiration date.
 * //www  .  j a  v a  2  s  .c o  m
 * @param date
 */
protected void setExpirationDate(LocalDate date) {

    this.expiryYear = Years.years(date.getYear());
    this.expiryMonth = Months.months(date.getMonthOfYear());
}