1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
|
public double calculate ()
{
Calendar startdate = Calendar.getInstance();
Calendar enddate = Calendar.getInstance();
Calendar startdatenew = Calendar.getInstance();
Calendar startdatum = Calendar.getInstance();
enddate.set(endyear, (endmonth - 1), endday + 1 , 12, 0, 0);
startdate.set(startyear, (startmonth -1 ), startday, 12, 0, 0);
startdatenew.set(startyear, (startmonth -1 ), startday, 12, 0, 0);
startdatum.set(startyear, (startmonth -1 ), startday, 12, 0, 1);
startdatum.add(Calendar.DATE, - 1);
LinkedList werteliste = new LinkedList ();
System.out.println("Startdatum: "+startdate.getTime()+" Endedatum: "+ enddate.getTime());
for ( startdatenew.set(startyear, (startmonth -1 ), startday, 12, 0, 0)
; startdatenew.before(enddate); startdatenew.add(Calendar.DATE, 1) ){
if (startdatenew.get(Calendar.MONTH) == 1 && startdatenew.get(Calendar.DAY_OF_MONTH) == 29)
{
Wertobjekt wert = new Wertobjekt(startdatum, startdatenew, startdate, startdate, fondswert, fondswert);
werteliste.add(wert);
}
else
{
double difference, days;
difference = startdatenew.getTimeInMillis() - startdate.getTimeInMillis();
days =difference/(24*3600*1000);
if (days == 0.0)
{
startdatum.add(Calendar.DATE, 1);
startdatum.add(Calendar.SECOND, - 1);
}
double prozent = 1 + (percent / 100);
double n = (days / 365);
double endvalue = Math.pow( prozent, n );
fondswert = price * endvalue;
Wertobjekt wert = new Wertobjekt(startdatum, startdatenew, startdate, startdate, fondswert, fondswert);
werteliste.add(wert);
if (days == 0.0)
{
startdatum.add(Calendar.DATE, - 1);
startdatum.add(Calendar.SECOND, 1);
}
}
startdatum.add(Calendar.DATE, 1);
}
|