18 package org.turro.financials.model.asset;
20 import java.util.Date;
21 import java.util.TreeMap;
22 import org.amic.util.date.DateRange;
30 public double getToDepreciate(
double investment, Date initialDate, Date finalDate) {
31 double toDepreciate = 0.0;
32 Date initialPeriod =
null;
34 for(Date finalPeriod : keySet()) {
35 if(finalPeriod.after(finalDate)) {
38 if(de !=
null && initialPeriod !=
null) {
39 Date range[] = DateRange.getFinalRange(initialDate, finalDate, initialPeriod, finalPeriod);
49 de =
get(finalPeriod);
50 initialPeriod = finalPeriod;
52 if(de !=
null && initialPeriod !=
null) {
53 Date range[] = DateRange.getFinalRange(initialDate, finalDate, initialPeriod, finalDate);
63 return Math.abs(toDepreciate) <= Math.abs(investment) ? toDepreciate : investment;
66 static final double ONE_HOUR = 60 * 60 * 1000L;
68 return ( (d2.getTime() - d1.getTime() + ONE_HOUR) /
static double daysBetween(Date d1, Date d2)
double getToDepreciate(double investment, Date initialDate, Date finalDate)