Example usage for org.joda.time LocalDate fromDateFields

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

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public static LocalDate fromDateFields(Date date) 

Source Link

Document

Constructs a LocalDate from a java.util.Date using exactly the same field values.

Usage

From source file:at.jclehner.rxdroid.db.Drug.java

License:Open Source License

public LocalDate getScheduleEndDate() {
    return scheduleEndDate != null ? LocalDate.fromDateFields(scheduleEndDate) : null;
}

From source file:at.jclehner.rxdroid.db.Entries.java

License:Open Source License

public static boolean hasLowSupplies(Drug drug, Date date) {
    if (!drug.isActive() || drug.getRefillSize() == 0 || drug.hasNoDoses())
        return false;

    final int minSupplyDays = Settings.getStringAsInt(Settings.Keys.LOW_SUPPLY_THRESHOLD, 10);
    if (minSupplyDays == 0)
        return false;

    final int supplyDaysLeft = getSupplyDaysLeftForDrug(drug, date);

    final LocalDate scheduleEnd = drug.getScheduleEndDate();
    if (scheduleEnd != null) {
        if (supplyDaysLeft >= Days.daysBetween(scheduleEnd, LocalDate.fromDateFields(date)).getDays())
            return false;
    }//from ww w  .ja  v  a2  s  .c  om

    return getSupplyDaysLeftForDrug(drug, date) < minSupplyDays;
}

From source file:at.jclehner.rxdroid.db.Entries.java

License:Open Source License

public static LocalDate getSupplyEndDate(Drug drug, Date date) {
    return LocalDate.fromDateFields(date).plusDays(getSupplyDaysLeftForDrug(drug, date));
}

From source file:at.jclehner.rxdroid.db.Entries.java

License:Open Source License

public static boolean willExpireSoon(Drug drug, Date date) {
    if (!drug.isActive() || drug.getRefillSize() == 0)
        return false;

    final LocalDate expirationDate = drug.getExpiryDate();
    if (expirationDate == null)
        return false;

    final LocalDate scheduleEnd = drug.getScheduleEndDate();
    if (scheduleEnd != null && expirationDate.isAfter(scheduleEnd))
        return false;

    final int minSupplyDays = Settings.getStringAsInt(Settings.Keys.LOW_SUPPLY_THRESHOLD, 10);
    if (minSupplyDays == 0)
        return false;

    return LocalDate.fromDateFields(date).plusDays(minSupplyDays).isAfter(expirationDate);
}

From source file:at.jclehner.rxdroid.DrugEditFragment.java

License:Open Source License

private boolean fixInvalidRepeatOrigin(final Drug drug) {
    final LocalDate dateOnly = LocalDate.fromDateFields(drug.getRepeatOrigin());

    if (fixInvalidRepeatOrigin(drug, dateOnly))
        return true;
    else if (fixInvalidRepeatOrigin(drug, drug.getNextScheduledDate(LocalDate.now())))
        return true;
    else {//from www  . j  a v a  2 s .c o m
        final DatePickerDialog dialog = new DatePickerDialog(getActivity(), dateOnly,
                new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePickerDialog dialog, LocalDate date) {
                        updateRepeatOrigin(drug, date);
                        updatePreferenceHierarchy();
                    }
                });
        dialog.setTitle(R.string._title_repetition_origin);
        dialog.setCancelable(false);
        dialog.show();
        return false;
    }
}

From source file:at.struct.wasbug21.converter.JodaTimeValueHandler.java

License:Apache License

@Override
public Object toObjectValue(ValueMapping vm, Object val) {
    if (vm.getType() == LocalTime.class) {
        return LocalTime.fromDateFields((Date) val);
    } else if (vm.getType() == LocalDate.class) {
        return LocalDate.fromDateFields((Date) val);
    } else if (vm.getType() == LocalDateTime.class) {
        return LocalDateTime.fromCalendarFields((Calendar) val);
    }// w  w w. ja v a  2 s  .com

    throw new IllegalStateException(
            "only LocalTime, LocalDate and LocalDateTime can be handled with this ValueHandler");
}

From source file:br.com.tecsinapse.exporter.converter.LocalDateTableCellConverter.java

License:LGPL

@Override
public LocalDate apply(Date input) {
    return LocalDate.fromDateFields(input);
}

From source file:candlelight.joda.converters.JodaLocalDateConverter.java

License:Apache License

public LocalDate convertToEntityAttribute(Date date) {
    return LocalDate.fromDateFields(date);
}

From source file:com.chiorichan.http.ssl.CertificateWrapper.java

License:Mozilla Public License

/**
 * Returns the number of days left on this certificate
 * Will return -1 if already expired//from ww  w.  ja va  2 s .  c o  m
 */
public int daysRemaining() {
    if (isExpired())
        return -1;
    return Days.daysBetween(LocalDate.fromDateFields(new Date()), LocalDate.fromDateFields(cert.getNotAfter()))
            .getDays();
}

From source file:com.divudi.bean.pharmacy.ReportsTransfer.java

public void fillMovingWithStock() {
    String sql;/*from   w  ww .j a  v a 2 s  . c  om*/
    Map m = new HashMap();
    m.put("i", institution);
    m.put("t1", BillType.PharmacyTransferIssue);
    m.put("t2", BillType.PharmacyPre);
    m.put("fd", fromDate);
    m.put("td", toDate);
    BillItem bi = new BillItem();

    sql = "select bi.item, abs(SUM(bi.pharmaceuticalBillItem.qty)), "
            + "abs(SUM(bi.pharmaceuticalBillItem.stock.itemBatch.purcahseRate * bi.pharmaceuticalBillItem.qty)), "
            + "SUM(bi.pharmaceuticalBillItem.stock.itemBatch.retailsaleRate * bi.qty)) "
            + "FROM BillItem bi where bi.retired=false and  bi.bill.department.institution=:i and "
            + "(bi.bill.billType=:t1 or bi.bill.billType=:t2) and "
            + "bi.bill.billDate between :fd and :td group by bi.item "
            + "order by  SUM(bi.pharmaceuticalBillItem.qty) desc";
    List<Object[]> objs = getBillItemFacade().findAggregates(sql, m);
    movementRecordsQty = new ArrayList<>();
    for (Object[] obj : objs) {
        StockReportRecord r = new StockReportRecord();
        r.setItem((Item) obj[0]);
        r.setQty((Double) obj[1]);
        Days daysBetween = Days.daysBetween(LocalDate.fromDateFields(fromDate),
                LocalDate.fromDateFields(toDate));
        int ds = daysBetween.getDays();
        r.setPurchaseValue((Double) (r.getQty() / ds));
        //            r.setRetailsaleValue((Double) obj[2]);
        r.setStockQty(getPharmacyBean().getStockQty(r.getItem(), institution));
        movementRecordsQty.add(r);
    }
}