Example usage for org.joda.time LocalDate toString

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

Introduction

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

Prototype

@ToString
public String toString() 

Source Link

Document

Output the date time in ISO8601 format (yyyy-MM-dd).

Usage

From source file:julian.lylly.model.Prospect.java

public List<Pair<Duration, Duration>> getBudgets(LocalDate pointer, Duration timespent) {
    int relDay = Days.daysBetween(start, pointer).getDays();
    if (pointer.isBefore(start) || !end.isAfter(pointer)) {
        throw new IllegalArgumentException("day is out of range:\t" + "start = " + start.toString() + "\t"
                + "pointer = " + pointer.toString() + "\t" + "end = " + end.toString());
    }//  www  .  j  a v  a2 s  . c  o m
    List<Integer> subl = weights.subList(relDay, weights.size());
    int sum = 0;
    for (int k : subl) {
        sum += k;
    }

    Duration minleft = Util.max(Duration.ZERO, min.minus(timespent));
    Duration maxleft = Util.max(Duration.ZERO, max.minus(timespent));

    List<Pair<Duration, Duration>> res = new ArrayList<>();
    for (int k : subl) {
        Duration bMin = minleft.multipliedBy(k).dividedBy(sum);
        Duration bMax = maxleft.multipliedBy(k).dividedBy(sum);
        res.add(new Pair(bMin, bMax));
    }
    return res;
}

From source file:me.vertretungsplan.parser.WebUntisParser.java

License:Mozilla Public License

private JSONObject getMessagesOfDay(LocalDate date)
        throws JSONException, CredentialInvalidException, IOException, UnauthorizedException {
    // messages only seem to work if they are set as "public" in WebUntis.
    loginInternal();// w ww  .  j a v a  2  s  . c om
    JSONObject params = new JSONObject();
    params.put("date", date.toString());
    return (JSONObject) request("getMessagesOfDay", params, true);
}

From source file:module.workingCapital.presentationTier.action.WorkingCapitalAction.java

License:Open Source License

private ActionForward exportInfoToExcel(Set<WorkingCapitalProcess> processes, WorkingCapitalContext context,
        HttpServletResponse response) throws Exception {

    final Integer year = context.getWorkingCapitalYear().getYear();
    SheetData<WorkingCapitalProcess> sheetData = new SheetData<WorkingCapitalProcess>(processes) {
        @Override/* w  ww.  j  a va 2 s .  c o  m*/
        protected void makeLine(WorkingCapitalProcess workingCapitalProcess) {
            if (workingCapitalProcess == null) {
                return;
            }
            final WorkingCapital workingCapital = workingCapitalProcess.getWorkingCapital();
            final WorkingCapitalInitialization initialization = workingCapital
                    .getWorkingCapitalInitialization();
            final AccountingUnit accountingUnit = workingCapital.getAccountingUnit();

            addCell(getLocalizedMessate("label.module.workingCapital.year"), year);
            addCell(getLocalizedMessate("label.module.workingCapital"),
                    workingCapitalProcess.getWorkingCapital().getUnit().getPresentationName());
            addCell(getLocalizedMessate("WorkingCapitalProcessState"),
                    workingCapitalProcess.getPresentableAcquisitionProcessState().getLocalizedName());
            addCell(getLocalizedMessate("label.module.workingCapital.unit.responsible"),
                    getUnitResponsibles(workingCapital));
            addCell(getLocalizedMessate("label.module.workingCapital.initialization.accountingUnit"),
                    accountingUnit == null ? "" : accountingUnit.getName());

            addCell(getLocalizedMessate("label.module.workingCapital.requestingDate"),
                    initialization.getRequestCreation().toString("yyyy-MM-dd HH:mm:ss"));
            addCell(getLocalizedMessate("label.module.workingCapital.requester"),
                    initialization.getRequestor().getName());
            final Person movementResponsible = workingCapital.getMovementResponsible();
            addCell(getLocalizedMessate("label.module.workingCapital.movementResponsible"),
                    movementResponsible == null ? "" : movementResponsible.getName());
            addCell(getLocalizedMessate("label.module.workingCapital.fiscalId"), initialization.getFiscalId());
            addCell(getLocalizedMessate("label.module.workingCapital.internationalBankAccountNumber"),
                    initialization.getInternationalBankAccountNumber());
            addCell(getLocalizedMessate("label.module.workingCapital.fundAllocationId"),
                    initialization.getFundAllocationId());
            final Money requestedAnualValue = initialization.getRequestedAnualValue();
            addCell(getLocalizedMessate("label.module.workingCapital.requestedAnualValue.requested"),
                    requestedAnualValue);
            addCell(getLocalizedMessate("label.module.workingCapital.requestedMonthlyValue.requested"),
                    requestedAnualValue.divideAndRound(new BigDecimal(6)));
            final Money authorizedAnualValue = initialization.getAuthorizedAnualValue();
            addCell(getLocalizedMessate("label.module.workingCapital.authorizedAnualValue"),
                    authorizedAnualValue == null ? "" : authorizedAnualValue);
            final Money maxAuthorizedAnualValue = initialization.getMaxAuthorizedAnualValue();
            addCell(getLocalizedMessate("label.module.workingCapital.maxAuthorizedAnualValue"),
                    maxAuthorizedAnualValue == null ? "" : maxAuthorizedAnualValue);
            final DateTime lastSubmission = initialization.getLastSubmission();
            addCell(getLocalizedMessate("label.module.workingCapital.initialization.lastSubmission"),
                    lastSubmission == null ? "" : lastSubmission.toString("yyyy-MM-dd"));
            final DateTime refundRequested = initialization.getRefundRequested();
            addCell(getLocalizedMessate("label.module.workingCapital.initialization.refundRequested"),
                    refundRequested == null ? "" : refundRequested.toString("yyyy-MM-dd"));

            final WorkingCapitalTransaction lastTransaction = workingCapital.getLastTransaction();
            if (lastTransaction == null) {
                addCell(getLocalizedMessate("label.module.workingCapital.transaction.accumulatedValue"),
                        Money.ZERO);
                addCell(getLocalizedMessate("label.module.workingCapital.transaction.balance"), Money.ZERO);
                addCell(getLocalizedMessate("label.module.workingCapital.transaction.debt"), Money.ZERO);
            } else {
                addCell(getLocalizedMessate("label.module.workingCapital.transaction.accumulatedValue"),
                        lastTransaction.getAccumulatedValue());
                addCell(getLocalizedMessate("label.module.workingCapital.transaction.balance"),
                        lastTransaction.getBalance());
                addCell(getLocalizedMessate("label.module.workingCapital.transaction.debt"),
                        lastTransaction.getDebt());
            }

            for (final AcquisitionClassification classification : WorkingCapitalSystem.getInstance()
                    .getAcquisitionClassificationsSet()) {
                final String description = classification.getDescription();
                final String pocCode = classification.getPocCode();
                final String key = pocCode + " - " + description;

                final Money value = calculateValueForClassification(workingCapital, classification);

                addCell(key, value);
            }

        }

        private Money calculateValueForClassification(final WorkingCapital workingCapital,
                final AcquisitionClassification classification) {
            Money result = Money.ZERO;
            for (final WorkingCapitalTransaction transaction : workingCapital
                    .getWorkingCapitalTransactionsSet()) {
                if (transaction.isAcquisition()) {
                    final WorkingCapitalAcquisitionTransaction acquisitionTransaction = (WorkingCapitalAcquisitionTransaction) transaction;
                    final WorkingCapitalAcquisition acquisition = acquisitionTransaction
                            .getWorkingCapitalAcquisition();
                    final AcquisitionClassification acquisitionClassification = acquisition
                            .getAcquisitionClassification();
                    if (acquisitionClassification == classification) {
                        result = result.add(acquisition.getValueAllocatedToSupplier());
                    }
                }
            }
            return result;
        }

        private String getUnitResponsibles(final WorkingCapital workingCapital) {
            final StringBuilder builder = new StringBuilder();
            final SortedMap<Person, Set<Authorization>> authorizations = workingCapital
                    .getSortedAuthorizations();
            if (!authorizations.isEmpty()) {
                for (final Entry<Person, Set<Authorization>> entry : authorizations.entrySet()) {
                    if (builder.length() > 0) {
                        builder.append("; ");
                    }
                    builder.append(entry.getKey().getName());
                }
            }

            return builder.toString();
        }

    };

    final LocalDate currentLocalDate = new LocalDate();
    final SpreadsheetBuilder builder = new SpreadsheetBuilder();
    builder.addConverter(Money.class, new CellConverter() {

        @Override
        public Object convert(final Object source) {
            final Money money = (Money) source;
            return money == null ? null : money.getRoundedValue().doubleValue();
        }

    });

    builder.addSheet(getLocalizedMessate("label.module.workingCapital") + " " + year + " - "
            + currentLocalDate.toString(), sheetData);

    final List<WorkingCapitalTransaction> transactions = new ArrayList<WorkingCapitalTransaction>();
    for (final WorkingCapitalProcess process : processes) {
        final WorkingCapital workingCapital = process.getWorkingCapital();
        transactions.addAll(workingCapital.getSortedWorkingCapitalTransactions());
    }
    final SheetData<WorkingCapitalTransaction> transactionsSheet = new SheetData<WorkingCapitalTransaction>(
            transactions) {
        @Override
        protected void makeLine(WorkingCapitalTransaction transaction) {
            final WorkingCapital workingCapital = transaction.getWorkingCapital();
            final WorkingCapitalProcess workingCapitalProcess = workingCapital.getWorkingCapitalProcess();

            addCell(getLocalizedMessate("label.module.workingCapital.year"), year);
            addCell(getLocalizedMessate("label.module.workingCapital"),
                    workingCapitalProcess.getWorkingCapital().getUnit().getPresentationName());
            addCell(getLocalizedMessate("label.module.workingCapital.transaction.number"),
                    transaction.getNumber());
            addCell(getLocalizedMessate("WorkingCapitalProcessState.CANCELED"),
                    transaction.isCanceledOrRejected() ? getLocalizedMessate("label.yes")
                            : getLocalizedMessate("label.no"));
            addCell(getLocalizedMessate("label.module.workingCapital.transaction.description") + " "
                    + getLocalizedMessate("label.module.workingCapital.transaction.number"),
                    transaction.getDescription());
            addCell(getLocalizedMessate("label.module.workingCapital.transaction.approval"),
                    approvalLabel(transaction));
            addCell(getLocalizedMessate("label.module.workingCapital.transaction.verification"),
                    verificationLabel(transaction));
            addCell(getLocalizedMessate("label.module.workingCapital.transaction.value"),
                    transaction.getValue());
            addCell(getLocalizedMessate("label.module.workingCapital.transaction.accumulatedValue"),
                    transaction.getAccumulatedValue());
            addCell(getLocalizedMessate("label.module.workingCapital.transaction.balance"),
                    transaction.getBalance());
            addCell(getLocalizedMessate("label.module.workingCapital.transaction.debt"), transaction.getDebt());

            if (transaction.isAcquisition()) {
                final WorkingCapitalAcquisitionTransaction acquisitionTx = (WorkingCapitalAcquisitionTransaction) transaction;
                final WorkingCapitalAcquisition acquisition = acquisitionTx.getWorkingCapitalAcquisition();
                final AcquisitionClassification acquisitionClassification = acquisition
                        .getAcquisitionClassification();
                final String economicClassification = acquisitionClassification.getEconomicClassification();
                final String pocCode = acquisitionClassification.getPocCode();
                addCell(getLocalizedMessate(
                        "label.module.workingCapital.configuration.acquisition.classifications.economicClassification"),
                        economicClassification);
                addCell(getLocalizedMessate(
                        "label.module.workingCapital.configuration.acquisition.classifications.pocCode"),
                        pocCode);
                addCell(getLocalizedMessate(
                        "label.module.workingCapital.configuration.acquisition.classifications.description"),
                        acquisition.getDescription());
            }
        }

        private Object verificationLabel(final WorkingCapitalTransaction transaction) {
            if (transaction.isAcquisition()) {
                final WorkingCapitalAcquisitionTransaction acquisition = (WorkingCapitalAcquisitionTransaction) transaction;
                if (acquisition.getWorkingCapitalAcquisition().getVerified() != null) {
                    return getLocalizedMessate("label.verified");
                }
                if (acquisition.getWorkingCapitalAcquisition().getNotVerified() != null) {
                    return getLocalizedMessate("label.notVerified");
                }
            }
            return "-";
        }

        private String approvalLabel(final WorkingCapitalTransaction transaction) {
            if (transaction.isAcquisition()) {
                final WorkingCapitalAcquisitionTransaction acquisition = (WorkingCapitalAcquisitionTransaction) transaction;
                if (acquisition.getWorkingCapitalAcquisition().getApproved() != null) {
                    return getLocalizedMessate("label.approved");
                }
                if (acquisition.getWorkingCapitalAcquisition().getRejectedApproval() != null) {
                    return getLocalizedMessate("label.rejected");
                }
            }
            return "-";
        }

    };
    builder.addSheet(getLocalizedMessate("label.module.workingCapital.transactions"), transactionsSheet);

    return streamSpreadsheet(response, "FundosManeio_" + year + "-" + currentLocalDate.getDayOfMonth() + "-"
            + currentLocalDate.getMonthOfYear() + "-" + currentLocalDate.getYear(), builder);

}

From source file:net.modelbased.proasense.adapter.imm.IMMOracleAdapter.java

License:Apache License

protected int convertToSimpleEvent(int prevCount, Connection con, HashMap map, HashMap idToMap,
        String nameAndDate, String sensorId) throws SQLException, InterruptedException {

    LocalDate localDate = new LocalDate();
    String[] tableNameAndDate = nameAndDate.split(",");
    String creationDate[] = tableNameAndDate[1].split(" ");
    String tableName = tableNameAndDate[0];
    int newRowCount = 0;

    ResultSet result;/*ww w  .  j a  v a 2  s.  c  om*/
    java.sql.PreparedStatement statement;

    while (true) {
        Thread.sleep(pollIntervall);

        statement = con.prepareStatement("select count(*) from " + tableName);
        result = statement.executeQuery();

        logger.debug("Waiting in inner loop for new rows in the database.");
        if (result.next()) {
            newRowCount = Integer.parseInt(result.getString(1));
        }

        if (creationDate[0].compareTo(localDate.toString()) < 0) {
            try {
                if (prevCount < newRowCount)
                    filterData(con, tableName, map, idToMap, prevCount, newRowCount);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            prevCount = newRowCount;
            return prevCount;
        }

        try {
            if (newRowCount > prevCount)
                filterData(con, tableName, map, idToMap, prevCount, newRowCount);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        prevCount = newRowCount;
        statement.close();
    }
}

From source file:net.sourceforge.fenixedu.domain.reports.TeachersListFromGiafReportFile.java

License:Open Source License

private String writeDate(LocalDate localDate) {
    return localDate == null ? null : localDate.toString();
}

From source file:nl.welteninstituut.tel.la.importers.rescuetime.RescueTimeTask.java

License:Open Source License

private JSONObject getData(final String apiKey, final LocalDate date)
        throws MalformedURLException, JSONException, IOException {
    String uri = String.format(URI_FORMAT, apiKey, date.toString());

    JSONObject data = new JSONObject(readURL(new URL(uri)));
    if (data.has("error")) {
        throw new JSONException(data.getString("error"));
    }/*from  w ww .ja v a  2  s.  co m*/

    return data;
}

From source file:no.digipost.api.client.representations.xml.DateXmlAdapter.java

License:Apache License

@Override
public String marshal(final LocalDate date) {
    return date.toString();
}

From source file:no.digipost.xsd.jaxb.XSDateCustomBinder.java

License:Apache License

public static String printDate(final LocalDate date) {
    return date.toString();
}

From source file:org.apache.cayenne.joda.access.types.LocalDateType.java

License:Apache License

@Override
public String toString(LocalDate value) {
    if (value == null) {
        return "NULL";
    }/* w  ww .  j  a v a2 s .  c  om*/

    return '\'' + value.toString() + '\'';
}

From source file:org.apache.fineract.accounting.closure.bookoffincomeandexpense.service.CalculateIncomeAndExpenseBookingImpl.java

License:Apache License

private IncomeAndExpenseBookingData bookOffIncomeAndExpense(
        final List<IncomeAndExpenseJournalEntryData> incomeAndExpenseJournalEntryDataList,
        final GLClosureCommand closureData, final boolean preview, final GLAccount glAccount,
        final Office office) {
    /* All running balances has to be calculated before booking off income and expense account */
    boolean isRunningBalanceCalculated = true;
    for (final IncomeAndExpenseJournalEntryData incomeAndExpenseData : incomeAndExpenseJournalEntryDataList) {
        if (!incomeAndExpenseData.isRunningBalanceCalculated()) {
            throw new RunningBalanceNotCalculatedException(incomeAndExpenseData.getOfficeId());
        }//from  ww w . jav a  2 s .c  om
    }
    BigDecimal debits = BigDecimal.ZERO;
    BigDecimal credits = BigDecimal.ZERO;

    final List<SingleDebitOrCreditEntry> debitsJournalEntry = new ArrayList<>();
    final List<SingleDebitOrCreditEntry> creditsJournalEntry = new ArrayList<>();

    for (final IncomeAndExpenseJournalEntryData incomeAndExpense : incomeAndExpenseJournalEntryDataList) {
        if (incomeAndExpense.isIncomeAccountType()) {
            if (incomeAndExpense.getOfficeRunningBalance().signum() == 1) {
                debits = debits.add(incomeAndExpense.getOfficeRunningBalance());
                debitsJournalEntry.add(new SingleDebitOrCreditEntry(incomeAndExpense.getAccountId(),
                        incomeAndExpense.getGlAccountName(), incomeAndExpense.getOfficeRunningBalance(), null));
            } else {
                credits = credits.add(incomeAndExpense.getOfficeRunningBalance().abs());
                creditsJournalEntry.add(new SingleDebitOrCreditEntry(incomeAndExpense.getAccountId(),
                        incomeAndExpense.getGlAccountName(), incomeAndExpense.getOfficeRunningBalance().abs(),
                        null));
                ;
            }
        }
        if (incomeAndExpense.isExpenseAccountType()) {
            if (incomeAndExpense.getOfficeRunningBalance().signum() == 1) {
                credits = credits.add(incomeAndExpense.getOfficeRunningBalance());
                creditsJournalEntry.add(new SingleDebitOrCreditEntry(incomeAndExpense.getAccountId(),
                        incomeAndExpense.getGlAccountName(), incomeAndExpense.getOfficeRunningBalance().abs(),
                        null));
                ;
            } else {
                debits = debits.add(incomeAndExpense.getOfficeRunningBalance().abs());
                debitsJournalEntry.add(new SingleDebitOrCreditEntry(incomeAndExpense.getAccountId(),
                        incomeAndExpense.getGlAccountName(), incomeAndExpense.getOfficeRunningBalance().abs(),
                        null));
            }
        }
    }
    final LocalDate today = DateUtils.getLocalDateOfTenant();
    final int compare = debits.compareTo(credits);
    BigDecimal difference = BigDecimal.ZERO;
    JournalEntry journalEntry = null;
    if (compare == 1) {
        /* book with target gl id on the credit side */
        difference = debits.subtract(credits);
        SingleDebitOrCreditEntry targetBooking = new SingleDebitOrCreditEntry(
                closureData.getEquityGlAccountId(), glAccount.getName(), difference, null);
        creditsJournalEntry.add(targetBooking);
        journalEntry = new JournalEntry(office.getId(), today.toString(), closureData.getComments(),
                creditsJournalEntry, debitsJournalEntry, null, false, closureData.getCurrencyCode(),
                office.getName());
    } else if (compare == -1) {
        /* book with target gl id on the debit side*/
        difference = credits.subtract(debits);
        SingleDebitOrCreditEntry targetBooking = new SingleDebitOrCreditEntry(
                closureData.getEquityGlAccountId(), glAccount.getName(), difference, null);
        debitsJournalEntry.add(targetBooking);
        journalEntry = new JournalEntry(office.getId(), today.toString(), closureData.getComments(),
                creditsJournalEntry, debitsJournalEntry, null, false, closureData.getCurrencyCode(),
                office.getName());
    } else if (compare == 0) {
        //throw new RunningBalanceZeroException(office.getName());
    }
    final LocalDate localDate = LocalDate.now();
    final List<JournalEntry> journalEntries = new ArrayList<>();
    if (journalEntry != null) {
        journalEntries.add(journalEntry);
    }

    return new IncomeAndExpenseBookingData(localDate, closureData.getComments(), journalEntries);
}