Example usage for org.joda.time YearMonthDay toString

List of usage examples for org.joda.time YearMonthDay toString

Introduction

In this page you can find the example usage for org.joda.time YearMonthDay toString.

Prototype

public String toString(String pattern) 

Source Link

Document

Output the date using the specified format pattern.

Usage

From source file:org.fenixedu.idcards.ui.candidacydocfiller.SantanderPdfFiller.java

License:Open Source License

private ByteArrayOutputStream getFilledPdfSantanderApplication(Person person)
        throws IOException, DocumentException {
    InputStream istream = getClass().getResourceAsStream(SANTANDER_APPLICATION_PDF_PATH);
    PdfReader reader = new PdfReader(istream);
    reader.getAcroForm().remove(PdfName.SIGFLAGS);
    reader.selectPages("1,2");
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PdfStamper stamper = new PdfStamper(reader, output);
    form = stamper.getAcroFields();/*from ww  w.ja  v  a  2s.  c om*/

    setField("topmostSubform[0].Page1[0].Nomecompleto[0]", person.getName());
    String documentIdNumber = person.getDocumentIdNumber();
    if (person.getIdDocumentType().equals(IDDocumentType.CITIZEN_CARD)
            || person.getIdDocumentType().equals(IDDocumentType.IDENTITY_CARD)) {
        setField("topmostSubform[0].Page1[0].NumBICartaoCidadaooutro[0]", documentIdNumber);
        setField("topmostSubform[0].Page1[0].Checkdigit[0]",
                person.getIdentificationDocumentSeriesNumberValue());
    } else {
        setField("topmostSubform[0].Page1[0].Outrotipodocidentificacao[0]", documentIdNumber);
    }

    YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay();
    if (emissionDate != null) {
        setField("topmostSubform[0].Page1[0].Dataemissao[0]",
                emissionDate.toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
    }
    setField("topmostSubform[0].Page1[0].Datavalidade[0]", person.getExpirationDateOfDocumentIdYearMonthDay()
            .toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
    setField("topmostSubform[0].Page1[0].NIF[0]", person.getSocialSecurityNumber());
    setField("topmostSubform[0].Page1[0].Datanascimento[0]",
            person.getDateOfBirthYearMonthDay().toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
    YearMonthDay dateOfBirthYearMonthDay = person.getDateOfBirthYearMonthDay();
    Period periodBetween = new Period(dateOfBirthYearMonthDay, new YearMonthDay());
    setField("topmostSubform[0].Page1[0].Idadeactual[0]",
            String.valueOf(periodBetween.get(DurationFieldType.years())));
    if (person.isFemale()) {
        setField("topmostSubform[0].Page1[0].Sexo[0]", "F"); // female
    } else if (person.isMale()) {
        setField("topmostSubform[0].Page1[0].Sexo[0]", "M"); // male
    }

    switch (person.getMaritalStatus()) {
    case CIVIL_UNION:
        setField("topmostSubform[0].Page1[0].Uniaofacto[0]", "1");
        break;
    case DIVORCED:
        setField("topmostSubform[0].Page1[0].Divorciado[0]", "1");
        break;
    case MARRIED:
        setField("topmostSubform[0].Page1[0].Casado[0]", "1");
        break;
    case SEPARATED:
        setField("topmostSubform[0].Page1[0].Separado[0]", "1");
        break;
    case SINGLE:
        setField("topmostSubform[0].Page1[0].Solteiro[0]", "1");
        break;
    case WIDOWER:
        setField("topmostSubform[0].Page1[0].Viuvo[0]", "1");
        break;
    }
    setField("topmostSubform[0].Page1[0].Telemovel[0]", person.getDefaultMobilePhoneNumber());
    setField("topmostSubform[0].Page1[0].E-mail[0]", getMail(person));

    setField("topmostSubform[0].Page1[0].Moradaresidenciapermanente[0]", person.getAddress());
    setField("topmostSubform[0].Page1[0].localidade[0]", person.getAreaOfAreaCode());
    String postalCode = person.getPostalCode();
    int dashIndex = postalCode.indexOf('-');
    setField("topmostSubform[0].Page1[0].CodPostal[0]", postalCode.substring(0, 4));
    String last3Numbers = person.getPostalCode().substring(dashIndex + 1, dashIndex + 4);
    setField("topmostSubform[0].Page1[0].ExtensaoCodPostal[0]", last3Numbers);

    setField("topmostSubform[0].Page1[0].Paisnacionalidade",
            person.getCountry().getCountryNationality().getPreferedContent());
    setField("topmostSubform[0].Page1[0].Paisnascimento", person.getCountryOfBirth().getName());
    setField("topmostSubform[0].Page1[0].Paisresidencia", person.getCountryOfResidence().getName());

    setField("topmostSubform[0].Page2[0].InstituioEnsinoSuperior[0]",
            UniversityUnit.getInstitutionsUniversityUnit().getName());
    setField("topmostSubform[0].Page2[0].FaculdadeEscola[0]",
            Bennu.getInstance().getInstitutionUnit().getName());
    Registration registration = getRegistration(person);
    if (registration != null) {
        setField("topmostSubform[0].Page2[0].Curso[0]", registration.getDegree().getSigla());
        setField("topmostSubform[0].Page2[0].AnoIncioCurso[0]",
                String.valueOf(registration.getStartDate().getYear()));
    }

    stamper.setFormFlattening(true);
    stamper.close();
    return output;
}

From source file:org.fenixedu.qubdocs.util.reports.helpers.DateHelper.java

License:Open Source License

public String date(final YearMonthDay yearMonthDay) {
    return yearMonthDay.toString("dd/MM/yyyy");
}

From source file:org.fenixedu.ulisboa.specifications.ui.firstTimeCandidacy.util.CGDPdfFiller.java

License:Open Source License

private ByteArrayOutputStream getFilledPdfCGDPersonalInformation(Person person, InputStream pdfTemplateStream)
        throws IOException, DocumentException {
    PdfReader reader = new PdfReader(pdfTemplateStream);
    reader.getAcroForm().remove(PdfName.SIGFLAGS);
    reader.selectPages("1,3,4"); // The template we are using has a blank page after the front sheet.
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PdfStamper stamper = new PdfStamper(reader, output);
    form = stamper.getAcroFields();/*  w  w w.  j a v a 2 s . co m*/

    setField("T_NomeComp", person.getName());
    setField("T_Email", getMail(person));

    if (person.isFemale()) {
        setField("CB_0_1", "Yes"); // female
    } else {
        setField("CB_0_0", "Yes"); // male
    }

    if (person.getDateOfBirthYearMonthDay() != null) {
        setField("Cod_data_1",
                person.getDateOfBirthYearMonthDay().toString(DateTimeFormat.forPattern("yyyy/MM/dd")));
    }

    setField("NIF1", person.getSocialSecurityNumber());
    setField("T_DocIdent", person.getDocumentIdNumber());

    switch (person.getMaritalStatus()) {
    case CIVIL_UNION:
        setField("CB_EstCivil01", MARITAL_STATUS_CIVIL_UNION);
        break;
    case DIVORCED:
        setField("CB_EstCivil01", MARITAL_STATUS_DIVORCED);
        break;
    case MARRIED:
        setField("CB_EstCivil01", "");
        break;
    case SEPARATED:
        setField("CB_EstCivil01", MARITAL_STATUS_SEPARATED);
        break;
    case SINGLE:
        setField("CB_EstCivil01", MARITAL_STATUS_SINGLE);
        break;
    case WIDOWER:
        setField("CB_EstCivil01", MARITAL_STATUS_WIDOWER);
        break;
    }
    YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay();
    if (emissionDate != null) {
        setField("Cod_data_2", emissionDate.toString(DateTimeFormat.forPattern("yyyy/MM/dd")));
    }

    YearMonthDay expirationDate = person.getExpirationDateOfDocumentIdYearMonthDay();
    if (expirationDate != null) {
        setField("Cod_data_3", expirationDate.toString(DateTimeFormat.forPattern("yyyy/MM/dd")));
    }

    setField("T_NomePai", person.getNameOfFather());
    setField("T_NomeMae", person.getNameOfMother());

    if (person.getCountryOfBirth() != null) {
        setField("T_NatPais", person.getCountryOfBirth().getName());
        setField("T_Naturali", person.getDistrictOfBirth());
        setField("T_NatConc", person.getDistrictSubdivisionOfBirth());
        setField("T_NatFreg", person.getParishOfBirth());
        setField("T_PaisRes", person.getCountryOfBirth().getCountryNationality().toString());
    }

    setField("T_Morada01", person.getAddress());
    setField("T_Localid01", person.getAreaOfAreaCode());
    setField("T_Telef", person.getDefaultMobilePhoneNumber());

    String postalCode = person.getPostalCode();
    int dashIndex = postalCode.indexOf('-');
    if (postalCode != null && postalCode.length() >= dashIndex + 4) {
        setField("T_CodPos01", postalCode.substring(0, 4));
        String last3Numbers = postalCode.substring(dashIndex + 1, dashIndex + 4);
        setField("T_CodPos03_1", last3Numbers);
        setField("T_Localid02_1", person.getAreaOfAreaCode());
    }

    if (person.getCountryOfResidence() != null) {
        setField("T_Distrito", person.getDistrictOfResidence());
        setField("T_Conc", person.getDistrictSubdivisionOfResidence());
        setField("T_Freguesia", person.getParishOfResidence());
        setField("T_PaisResid", person.getCountryOfResidence().getName());
    }

    stamper.setFormFlattening(true);
    stamper.close();
    return output;
}

From source file:org.fenixedu.ulisboa.specifications.ui.renderers.student.curriculum.StudentCurricularPlanLayout.java

License:Open Source License

protected void generateDismissalApprovementlDateIfRequired(HtmlTableRow enrolmentRow,
        YearMonthDay approvementDate) {
    if (isViewerAllowedToViewFullStudentCurriculum(studentCurricularPlan)) {
        if (approvementDate != null) {
            generateCellWithSpan(enrolmentRow, approvementDate.toString(DATE_FORMAT),
                    BundleUtil.getString(Bundle.APPLICATION, "label.data.avaliacao"),
                    renderer.getCreationDateCellClass());
        } else {//from  w w  w  .j  a  va2 s. c o  m
            generateCellWithText(enrolmentRow, EMPTY_INFO, renderer.getCreationDateCellClass());
        }
    }
}

From source file:org.fenixedu.ulisboa.specifications.ui.renderers.student.curriculum.StudentCurricularPlanLayout.java

License:Open Source License

protected void generateEvaluationDateIfRequired(HtmlTableRow externalEnrolmentRow,
        YearMonthDay evaluationDate) {
    if (isViewerAllowedToViewFullStudentCurriculum(studentCurricularPlan)) {
        if (evaluationDate != null) {
            generateCellWithSpan(externalEnrolmentRow, evaluationDate.toString(DATE_FORMAT),
                    BundleUtil.getString(Bundle.APPLICATION, "creationDate"),
                    renderer.getCreationDateCellClass());
        } else {/* w  w w .  j  av  a 2s . c om*/
            generateCellWithText(externalEnrolmentRow, EMPTY_INFO, renderer.getCreationDateCellClass());
        }
    }
}

From source file:org.fenixedu.ulisboa.specifications.ui.renderers.student.curriculum.StudentCurricularPlanLayout.java

License:Open Source License

protected void generateEnrolmentGradeCell(HtmlTableRow enrolmentRow, IEnrolment enrolment) {
    final Grade grade = enrolment.getGrade();

    // qubExtension
    final String text = grade.isEmpty() ? EMPTY_INFO : grade.getValue();
    String title = null;//from   www  . j  a  v  a2 s.c o m
    if (enrolment instanceof Enrolment) {
        final Enrolment specific = (Enrolment) enrolment;
        final EnrolmentEvaluation evaluation = specific.getFinalEnrolmentEvaluation();
        final YearMonthDay available = evaluation != null ? evaluation.getGradeAvailableDateYearMonthDay()
                : null;
        if (available != null) {
            title = ULisboaSpecificationsUtil.bundle("label.LooseEvaluationBean.availableDate")
                    + available.toString(DATE_FORMAT);
        }
    }

    final HtmlTableCell cell = generateCellWithSpan(enrolmentRow, text, title, null);
    cell.setStyle(grade.isApproved() ? GRADE_APPROVED_STYLE
            : grade.isNotApproved() ? GRADE_NOT_APPROVED_STYLE : GRADE_EMPTY_STYLE);
}

From source file:pt.utl.ist.codeGenerator.database.CreateTestData.java

License:Open Source License

private static String constructExecutionYearString(final YearMonthDay year1, final YearMonthDay year2) {
    return year1.toString("yyyy") + "/" + year2.toString("yyyy");
}