List of usage examples for org.joda.time LocalDate toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:org.flowable.dmn.engine.impl.el.util.DateUtil.java
License:Apache License
public static Date addDate(Object startDate, Object years, Object months, Object days) { LocalDate currentDate = new LocalDate(startDate); currentDate = currentDate.plusYears(intValue(years)); currentDate = currentDate.plusMonths(intValue(months)); currentDate = currentDate.plusDays(intValue(days)); return currentDate.toDate(); }
From source file:org.flowable.dmn.engine.impl.el.util.DateUtil.java
License:Apache License
public static Date subtractDate(Object startDate, Object years, Object months, Object days) { LocalDate currentDate = new LocalDate(startDate); currentDate = currentDate.minusYears(intValue(years)); currentDate = currentDate.minusMonths(intValue(months)); currentDate = currentDate.minusDays(intValue(days)); return currentDate.toDate(); }
From source file:org.fornax.cartridges.sculptor.framework.accessimpl.mongodb.JodaLocalDateMapper.java
License:Apache License
public Date toData(LocalDate from) { if (from == null) { return null; }//from w w w .j a v a 2s. c o m return from.toDateTimeAtStartOfDay().toDate(); }
From source file:org.gnucash.android.ui.report.linechart.CashFlowLineChartFragment.java
License:Apache License
/** * Returns a data object that represents a user data of the specified account types * @param accountTypeList account's types which will be displayed * @return a {@code LineData} instance that represents a user data */// w ww . j a v a 2 s .c om private LineData getData(List<AccountType> accountTypeList) { Log.w(TAG, "getData"); calculateEarliestAndLatestTimestamps(accountTypeList); // LocalDateTime? LocalDate startDate; LocalDate endDate; if (mReportPeriodStart == -1 && mReportPeriodEnd == -1) { startDate = new LocalDate(mEarliestTransactionTimestamp).withDayOfMonth(1); endDate = new LocalDate(mLatestTransactionTimestamp).withDayOfMonth(1); } else { startDate = new LocalDate(mReportPeriodStart).withDayOfMonth(1); endDate = new LocalDate(mReportPeriodEnd).withDayOfMonth(1); } int count = getDateDiff(new LocalDateTime(startDate.toDate().getTime()), new LocalDateTime(endDate.toDate().getTime())); Log.d(TAG, "X-axis count" + count); List<String> xValues = new ArrayList<>(); for (int i = 0; i <= count; i++) { switch (mGroupInterval) { case MONTH: xValues.add(startDate.toString(X_AXIS_PATTERN)); Log.d(TAG, "X-axis " + startDate.toString("MM yy")); startDate = startDate.plusMonths(1); break; case QUARTER: int quarter = getQuarter(new LocalDateTime(startDate.toDate().getTime())); xValues.add("Q" + quarter + startDate.toString(" yy")); Log.d(TAG, "X-axis " + "Q" + quarter + startDate.toString(" MM yy")); startDate = startDate.plusMonths(3); break; case YEAR: xValues.add(startDate.toString("yyyy")); Log.d(TAG, "X-axis " + startDate.toString("yyyy")); startDate = startDate.plusYears(1); break; // default: } } List<LineDataSet> dataSets = new ArrayList<>(); for (AccountType accountType : accountTypeList) { LineDataSet set = new LineDataSet(getEntryList(accountType), accountType.toString()); set.setDrawFilled(true); set.setLineWidth(2); set.setColor(COLORS[dataSets.size()]); set.setFillColor(FILL_COLORS[dataSets.size()]); dataSets.add(set); } LineData lineData = new LineData(xValues, dataSets); if (lineData.getYValueSum() == 0) { mChartDataPresent = false; return getEmptyData(); } return lineData; }
From source file:org.gnucash.android.ui.report.LineChartFragment.java
License:Apache License
/** * Returns a data object that represents a user data of the specified account types * @param accountTypeList account's types which will be displayed * @return a {@code LineData} instance that represents a user data *//*w w w .j a v a2s. com*/ private LineData getData(List<AccountType> accountTypeList) { Log.w(TAG, "getData"); calculateEarliestAndLatestTimestamps(accountTypeList); // LocalDateTime? LocalDate startDate; LocalDate endDate; if (mReportStartTime == -1 && mReportEndTime == -1) { startDate = new LocalDate(mEarliestTransactionTimestamp).withDayOfMonth(1); endDate = new LocalDate(mLatestTransactionTimestamp).withDayOfMonth(1); } else { startDate = new LocalDate(mReportStartTime).withDayOfMonth(1); endDate = new LocalDate(mReportEndTime).withDayOfMonth(1); } int count = getDateDiff(new LocalDateTime(startDate.toDate().getTime()), new LocalDateTime(endDate.toDate().getTime())); Log.d(TAG, "X-axis count" + count); List<String> xValues = new ArrayList<>(); for (int i = 0; i <= count; i++) { switch (mGroupInterval) { case MONTH: xValues.add(startDate.toString(X_AXIS_PATTERN)); Log.d(TAG, "X-axis " + startDate.toString("MM yy")); startDate = startDate.plusMonths(1); break; case QUARTER: int quarter = getQuarter(new LocalDateTime(startDate.toDate().getTime())); xValues.add("Q" + quarter + startDate.toString(" yy")); Log.d(TAG, "X-axis " + "Q" + quarter + startDate.toString(" MM yy")); startDate = startDate.plusMonths(3); break; case YEAR: xValues.add(startDate.toString("yyyy")); Log.d(TAG, "X-axis " + startDate.toString("yyyy")); startDate = startDate.plusYears(1); break; // default: } } List<LineDataSet> dataSets = new ArrayList<>(); for (AccountType accountType : accountTypeList) { LineDataSet set = new LineDataSet(getEntryList(accountType), accountType.toString()); set.setDrawFilled(true); set.setLineWidth(2); set.setColor(COLORS[dataSets.size()]); set.setFillColor(FILL_COLORS[dataSets.size()]); dataSets.add(set); } LineData lineData = new LineData(xValues, dataSets); if (lineData.getYValueSum() == 0) { mChartDataPresent = false; return getEmptyData(); } return lineData; }
From source file:org.jbpm.console.ng.ht.backend.server.TaskCalendarServiceImpl.java
License:Apache License
private Day transformLocalDateToDay(LocalDate localDate) { SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE dd"); Date dayDate = localDate.toDateTimeAtStartOfDay().toDate(); return new Day(dayDate, dayFormat.format(dayDate)); }
From source file:org.killbill.billing.plugin.avatax.api.AvaTaxTaxCalculator.java
License:Apache License
/** * Given some invoice items for a given invoice, prepare a GetTaxRequest for AvaTax. At this point, we've already * verified that these items need to be created and don't exist in AvaTax yet. * <p/>//from ww w. ja va 2s . com * Note that this will create either a Sales or a Return document, but not both. This means that * if <b>adjustmentItems</b> is specified, originalInvoiceReferenceCode must be specified and * the <b>taxableItems</b> must already be committed in AvaTax (Return). You cannot create and adjust items at the same time. * <p/> * In case of subsequent Return, only pass the new adjustments in <b>adjustmentItems</b>. * * @param account Kill Bill account * @param invoice Kill Bill invoice associated with the taxable items * @param taxableItems taxable invoice items associated with that invoice * @param adjustmentItems invoice item adjustments associated (empty for Sales document) * @param originalInvoiceReferenceCode the original AvaTax reference code (null for Sales document) * @param pluginProperties Kill Bill plugin properties * @param dryRun true if the invoice won't be persisted * @param utcToday today's date * @return GetTaxRequest object */ private GetTaxRequest toTaxRequest(final String companyCode, final Account account, final Invoice invoice, final Collection<InvoiceItem> taxableItems, @Nullable final Map<UUID, Collection<InvoiceItem>> adjustmentItems, @Nullable final String originalInvoiceReferenceCode, final boolean dryRun, final Iterable<PluginProperty> pluginProperties, final LocalDate utcToday) { Preconditions.checkState( (originalInvoiceReferenceCode == null && (adjustmentItems == null || adjustmentItems.isEmpty())) || (originalInvoiceReferenceCode != null && (adjustmentItems != null && !adjustmentItems.isEmpty())), "Invalid combination of originalInvoiceReferenceCode %s and adjustments %s", originalInvoiceReferenceCode, adjustmentItems); Preconditions.checkState( (adjustmentItems == null || adjustmentItems.isEmpty()) || adjustmentItems.size() == taxableItems.size(), "Invalid number of adjustments %s for taxable items %s", adjustmentItems, taxableItems); final GetTaxRequest taxRequest = new GetTaxRequest(); // The DocCode needs to be unique to be able to support multiple returns for the same invoice // Note: for certification, the invoice id needs to be part of the DocCode (we cannot use the invoice number, as it may not be known yet) // Also, DocCode length must be between 1 and 50 characters taxRequest.DocCode = String.format("%s_%s", invoice.getId(), UUID.randomUUID().toString().substring(0, 12)); // For returns, refers to the DocCode of the original invoice taxRequest.ReferenceCode = originalInvoiceReferenceCode; // AvaTax makes no direct association to the original invoice. We overload this field to keep a mapping with the original invoice. taxRequest.PurchaseOrderNo = invoice.getId().toString(); // We want to report the return in the period in which it was processed, but it may have calculated tax in a previous period (which had different tax rates). // To handle this, we send the DocDate as the date of return processing, and use TaxOverride.TaxDate to send the date of the original invoice. taxRequest.DocDate = utcToday.toDate(); taxRequest.CurrencyCode = invoice.getCurrency().name(); if (dryRun) { // This is a temporary document type and is not saved in tax history taxRequest.DocType = originalInvoiceReferenceCode == null ? DocType.SalesOrder : DocType.ReturnOrder; taxRequest.Commit = false; } else { // The document is a permanent invoice; document and tax calculation results are saved in the tax history taxRequest.DocType = originalInvoiceReferenceCode == null ? DocType.SalesInvoice : DocType.ReturnInvoice; // Commit the invoice in AvaTax taxRequest.Commit = true; } taxRequest.CustomerCode = MoreObjects.firstNonNull(account.getExternalKey(), account.getId()).toString(); taxRequest.Addresses = new Address[] { toAddress(account) }; taxRequest.Lines = new Line[taxableItems.size()]; // Create the individual line items final Iterator<InvoiceItem> taxableItemsIterator = taxableItems.iterator(); int i = 0; while (taxableItemsIterator.hasNext()) { final InvoiceItem taxableItem = taxableItemsIterator.next(); taxRequest.Lines[i] = toLine(invoice, taxableItem, adjustmentItems == null ? null : adjustmentItems.get(taxableItem.getId()), taxRequest.Addresses[0].AddressCode, pluginProperties); i++; } // Done at the line item level taxRequest.TaxOverride = null; taxRequest.CompanyCode = PluginProperties.getValue(PROPERTY_COMPANY_CODE, companyCode, pluginProperties); taxRequest.DetailLevel = DetailLevel.Tax; taxRequest.Client = CLIENT_NAME; taxRequest.CustomerUsageType = PluginProperties.findPluginPropertyValue(CUSTOMER_USAGE_TYPE, pluginProperties); // Nice-to-have (via plugin properties or tags?) taxRequest.ExemptionNo = null; taxRequest.Discount = BigDecimal.ZERO; // Required for VAT taxRequest.BusinessIdentificationNo = null; taxRequest.PaymentDate = null; taxRequest.PosLaneCode = null; return taxRequest; }
From source file:org.killbill.billing.usage.dao.DefaultRolledUpUsageDao.java
License:Apache License
@Override public List<RolledUpUsageModelDao> getUsageForSubscription(final UUID subscriptionId, final LocalDate startDate, final LocalDate endDate, final String unitType, final InternalTenantContext context) { return rolledUpUsageSqlDao.getUsageForSubscription(subscriptionId, startDate.toDate(), endDate.toDate(), unitType, context);//www. j ava 2 s . c o m }
From source file:org.killbill.billing.usage.dao.DefaultRolledUpUsageDao.java
License:Apache License
@Override public List<RolledUpUsageModelDao> getAllUsageForSubscription(final UUID subscriptionId, final LocalDate startDate, final LocalDate endDate, final InternalTenantContext context) { return rolledUpUsageSqlDao.getAllUsageForSubscription(subscriptionId, startDate.toDate(), endDate.toDate(), context);/* www . j a v a 2 s .c o m*/ }
From source file:org.killbill.billing.usage.dao.DefaultRolledUpUsageDao.java
License:Apache License
@Override public List<RolledUpUsageModelDao> getRawUsageForAccount(final LocalDate startDate, final LocalDate endDate, final InternalTenantContext context) { return rolledUpUsageSqlDao.getRawUsageForAccount(startDate.toDate(), endDate.toDate(), context); }