Example usage for org.apache.commons.lang3.time DateFormatUtils format

List of usage examples for org.apache.commons.lang3.time DateFormatUtils format

Introduction

In this page you can find the example usage for org.apache.commons.lang3.time DateFormatUtils format.

Prototype

public static String format(final Calendar calendar, final String pattern) 

Source Link

Document

Formats a calendar into a specific pattern.

Usage

From source file:org.gbif.ipt.action.manage.OverviewAction.java

/**
 * Log how many times publication has failed for a resource, also detailing when the failures occurred.
 * /*from   w w  w.ja v a  2  s  . co m*/
 * @param resource resource
 */
@VisibleForTesting
protected void logProcessFailures(Resource resource) {
    StringBuilder sb = new StringBuilder();
    sb.append("Resource [");
    sb.append(resource.getTitleAndShortname());
    sb.append("] has ");
    if (resourceManager.getProcessFailures().containsKey(resource.getShortname())) {
        List<Date> failures = resourceManager.getProcessFailures().get(resource.getShortname());
        sb.append(String.valueOf(failures.size()));
        sb.append(" failed publications on: ");
        Iterator<Date> iter = failures.iterator();
        while (iter.hasNext()) {
            sb.append(DateFormatUtils.format(iter.next(), "yyyy-MM-dd HH:mm:SS"));
            if (iter.hasNext()) {
                sb.append(", ");
            } else {
                sb.append(".");
            }
        }
    } else {
        sb.append("0 failed publications");
    }
    LOG.debug(sb.toString());
}

From source file:org.kuali.coeus.common.budget.impl.print.BudgetBaseStream.java

/**
 * This method gets ReportHeaderType from first budgetPeriod.It set all the
 * data for RportHeader from budgetPriod and budgetParent
 * //from w  w w  .  j  a  v  a  2  s  .c  o m
 * @param budgetParent
 * @return reportTypeHeader
 */
protected ReportHeaderType getReportHeaderTypeForCumulativeReport(BudgetParent budgetParent) {
    ReportHeaderType reportHeaderType = ReportHeaderType.Factory.newInstance();
    if (budgetParent != null) {
        reportHeaderType.setParentTypeName(budgetParent.getParentTypeName());
        reportHeaderType.setProposalNumber(budgetParent.getParentNumber());
    }
    if (budgetParent != null && budgetParent.getParentTitle() != null) {
        reportHeaderType.setProposalTitle(budgetParent.getParentTitle());
    }
    String principleInvestigatorName = budgetParent.getParentPIName();
    if (principleInvestigatorName != null) {
        reportHeaderType.setPIName(principleInvestigatorName);
    }
    if (budgetPeriod.getVersionNumber() != null) {
        reportHeaderType.setBudgetVersion(budget.getBudgetVersionNumber().intValue());
    }
    if (budgetPeriod.getStartDate() != null) {
        reportHeaderType.setPeriodStartDate(DateFormatUtils.format(budgetPeriod.getStartDate(), DATE_FORMAT));
    }
    if (budgetPeriod.getEndDate() != null) {
        reportHeaderType.setPeriodEndDate(DateFormatUtils.format(budgetPeriod.getEndDate(), DATE_FORMAT));
    }
    if (budgetPeriod.getBudgetPeriod() != null) {
        reportHeaderType.setPeriod(budgetPeriod.getBudgetPeriod());
    }
    reportHeaderType.setCreateDate(dateTimeService.getCurrentDate().toString());
    if (budget.getComments() != null) {
        if (budget.getPrintBudgetCommentFlag() != null && budget.getPrintBudgetCommentFlag().equals("true"))
            reportHeaderType.setComments(budget.getComments());
    }

    budget.setPrintBudgetCommentFlag(null);

    return reportHeaderType;
}

From source file:org.kuali.coeus.common.budget.impl.print.BudgetBaseStream.java

/**
 * This method gets reportType for LASalary by setting data from
 * reportTypeVO and passed parameters/*from  w  w w. ja v a 2  s  . com*/
 * 
 */
private ReportType getReportTypeForLASalary(ScaleTwoDecimal fringe, ScaleTwoDecimal salary,
        ScaleTwoDecimal calculatedCost, ScaleTwoDecimal calculatedCostSharing, ReportTypeVO reportTypeVO,
        Date startDate, Date endDate) {
    ReportType reportType = ReportType.Factory.newInstance();
    reportType.setBudgetCategoryDescription(LAB_ALLOCATION);
    reportType.setPersonName(ALLOCATED_ADMIN_SUPPORT);
    reportType.setPercentEffort(100);
    reportType.setPercentCharged(100);
    reportType.setBudgetCategoryCode(99);
    reportType.setInvestigatorFlag(3);
    reportType.setStartDate(DateFormatUtils.format(startDate, DATE_FORMAT_MMDDYY));
    reportType.setEndDate(DateFormatUtils.format(endDate, DATE_FORMAT_MMDDYY));
    reportType.setCostSharingAmount(calculatedCostSharing.doubleValue());
    reportType.setCalculatedCost(calculatedCost.doubleValue());
    reportType.setFringe(fringe.doubleValue());
    reportType.setCostElementDescription(reportTypeVO.getCostElementDesc());
    reportType.setSalaryRequested(salary.doubleValue());
    return reportType;
}

From source file:org.kuali.coeus.common.budget.impl.print.BudgetBaseStream.java

private ReportType getReportTypeForRateAndBase(Date startDate, Date endDate, ScaleTwoDecimal calculatedCost,
        ScaleTwoDecimal salaryRequested, ReportTypeVO reportTypeVO) {
    ReportType reportType = ReportType.Factory.newInstance();
    reportType.setSalaryRequested(salaryRequested.doubleValue());
    reportType.setCalculatedCost(calculatedCost.doubleValue());
    reportType.setStartDate(DateFormatUtils.format(startDate, DATE_FORMAT));
    reportType.setEndDate(DateFormatUtils.format(endDate, DATE_FORMAT));
    reportType.setAppliedRate(reportTypeVO.getAppliedRate().doubleValue());
    reportType.setRateClassDesc(reportTypeVO.getRateClassDesc());
    reportType.setRateTypeDesc(reportTypeVO.getRateTypeDesc());
    reportType.setOnOffCampus(reportTypeVO.getOnOffCampusFlag());
    return reportType;
}

From source file:org.kuali.coeus.common.budget.impl.print.BudgetBaseStream.java

private ReportType getReportTypeForBudgetOHRateAndBase(Date startDate, Date endDate,
        ScaleTwoDecimal calculatedCost, ScaleTwoDecimal salaryRequested, ReportTypeVO reportTypeVO) {
    ReportType reportType = ReportType.Factory.newInstance();
    reportType.setSalaryRequested(salaryRequested.doubleValue());
    reportType.setCalculatedCost(calculatedCost.doubleValue());
    reportType.setStartDate(DateFormatUtils.format(startDate, DATE_FORMAT));
    reportType.setEndDate(DateFormatUtils.format(endDate, DATE_FORMAT));
    reportType.setAppliedRate(reportTypeVO.getAppliedRate().doubleValue());
    reportType.setRateClassDesc(reportTypeVO.getRateClassDesc());
    reportType.setOnOffCampus(reportTypeVO.getOnOffCampusFlag());
    return reportType;
}

From source file:org.kuali.coeus.common.budget.impl.print.BudgetCumilativeXmlStream.java

protected ReportHeaderType getReportHeaderTypeForCumulativeReport(BudgetParent budgetParent) {
    ReportHeaderType reportHeaderType = ReportHeaderType.Factory.newInstance();
    if (budgetParent != null) {
        reportHeaderType.setParentTypeName(budgetParent.getParentTypeName());
        reportHeaderType.setProposalNumber(budgetParent.getParentNumber());
    }//from   w  w w. j a  v a  2 s  .  c om
    if (budgetParent != null && budgetParent.getParentTitle() != null) {
        reportHeaderType.setProposalTitle(budgetParent.getParentTitle());
    }
    String principleInvestigatorName = budgetParent.getParentPIName();

    if (principleInvestigatorName != null) {
        reportHeaderType.setPIName(principleInvestigatorName);
    }
    if (budget.getVersionNumber() != null) {
        reportHeaderType.setBudgetVersion(budget.getBudgetVersionNumber().intValue());
    }
    if (budget.getStartDate() != null) {
        reportHeaderType.setPeriodStartDate(DateFormatUtils.format(budget.getStartDate(), DATE_FORMAT));
    }
    if (budget.getEndDate() != null) {
        reportHeaderType.setPeriodEndDate(DateFormatUtils.format(budget.getEndDate(), DATE_FORMAT));
    }
    reportHeaderType.setCreateDate(dateTimeService.getCurrentDate().toString());
    if (budget.getComments() != null) {
        if (budget.getPrintBudgetCommentFlag() != null && budget.getPrintBudgetCommentFlag().equals("true"))
            reportHeaderType.setComments(budget.getComments());
    }

    budget.setPrintBudgetCommentFlag(null);

    return reportHeaderType;
}

From source file:org.kuali.coeus.common.budget.impl.print.IndustrialBudgetXmlStream.java

private ReportType getReportTypeForIndustrialBudgetSalary(ScaleTwoDecimal salary, ReportTypeVO reportTypeVO) {
    ReportType reportType = ReportType.Factory.newInstance();
    reportType.setStartDate(DateFormatUtils.format(reportTypeVO.getStartDate(), DATE_FORMAT_MMDDYY));
    reportType.setEndDate(DateFormatUtils.format(reportTypeVO.getEndDate(), DATE_FORMAT_MMDDYY));
    reportType.setBudgetCategoryDescription(reportTypeVO.getBudgetCategoryDesc());
    reportType.setPersonName(reportTypeVO.getPersonName());
    reportType.setPercentEffort(//from ww w  . jav a2  s  . c om
            reportTypeVO.getPercentEffort() != null ? reportTypeVO.getPercentEffort().doubleValue() : 0.00);
    reportType.setPercentCharged(
            reportTypeVO.getPercentCharged() != null ? reportTypeVO.getPercentCharged().doubleValue() : 0.00);
    if (reportTypeVO.getBudgetCategoryCode() != null) {
        reportType.setBudgetCategoryCode(Integer.parseInt(reportTypeVO.getBudgetCategoryCode()));
    }
    salary = salary.add(reportTypeVO.getSalaryRequested());
    reportType.setSalaryRequested(salary.doubleValue());
    reportType.setInvestigatorFlag(reportTypeVO.getInvestigatorFlag());
    reportType.setCostElementDescription(reportTypeVO.getCostElementDesc());
    return reportType;
}

From source file:org.kuali.coeus.propdev.impl.print.ProposalSubmissionXmlStream.java

private String getSponsorDeadLine(Date deadLineDate, String deadLineType) {
    String sponsorDeadLineType = Constants.EMPTY_STRING;
    String deadLineDateFormated = DateFormatUtils.format(deadLineDate, Constants.DEFAULT_DATE_FORMAT_PATTERN);
    if (SPONSOR_DEADLINE_TYPE_POSTMARK.equals(deadLineType)) {
        sponsorDeadLineType = SPONSOR_DEADLINE_POSTMARK_DESCRIPTION;
    } else if (SPONSOR_DEADLINE_TYPE_RECEIPT.equals(deadLineType)) {
        sponsorDeadLineType = SPONSOR_DEADLINE_RECEIPT_DESCRIPTION;
    }//from   w  w  w . j a v  a  2  s  .  co m
    String sponsorDeadLine = new StringBuilder(deadLineDateFormated).append(sponsorDeadLineType).toString();
    return sponsorDeadLine;
}

From source file:org.kuali.coeus.propdev.impl.print.ProposalSubmissionXmlStream.java

private String getProjectPeriod(Date requestedStartDate, Date requestedEndDate) {
    String startDate = DateFormatUtils.format(requestedStartDate, Constants.DEFAULT_DATE_FORMAT_PATTERN);
    String endDate = DateFormatUtils.format(requestedEndDate, Constants.DEFAULT_DATE_FORMAT_PATTERN);
    String projectPeriod = new StringBuilder(startDate).append(STRING_SEPRATOR).append(endDate).toString();
    return projectPeriod;
}

From source file:org.lazulite.boot.autoconfigure.core.xml.converter.SingleValueDateConverter.java

public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
    Date date = (Date) source;
    writer.setValue(DateFormatUtils.format(date, pattern));
}