Lines 63-69
Link Here
|
63 |
|
63 |
|
64 |
calStart.setTime( |
64 |
calStart.setTime( |
65 |
date); // If date includes hours, minutes, and seconds, set them to 0 |
65 |
date); // If date includes hours, minutes, and seconds, set them to 0 |
66 |
if (calStart.get(Calendar.YEAR) < 1900) |
66 |
return internalGetExcelDate(calStart); |
|
|
67 |
} |
68 |
|
69 |
/** |
70 |
* Given a Date, converts it into a double representing its internal Excel representation, |
71 |
* which is the number of days since 1/1/1900. Fractional days represent hours, minutes, and seconds. |
72 |
* |
73 |
* @return Excel representation of Date (-1 if error - test for error by checking for less than 0.1) |
74 |
* @param date the Date |
75 |
*/ |
76 |
public static double getExcelDate(Calendar date) |
77 |
{ |
78 |
return internalGetExcelDate((Calendar) date.clone()); |
79 |
} |
80 |
|
81 |
// The time will be change to the daystart |
82 |
private static double internalGetExcelDate(Calendar date) |
83 |
{ |
84 |
if (date.get(Calendar.YEAR) < 1900) |
67 |
{ |
85 |
{ |
68 |
return BAD_DATE; |
86 |
return BAD_DATE; |
69 |
} |
87 |
} |
Lines 76-89
Link Here
|
76 |
// be 4 hours. |
94 |
// be 4 hours. |
77 |
// E.g. 2004-03-28 04:00 CEST - 2004-03-28 00:00 CET is 3 hours |
95 |
// E.g. 2004-03-28 04:00 CEST - 2004-03-28 00:00 CET is 3 hours |
78 |
// and 2004-10-31 04:00 CET - 2004-10-31 00:00 CEST is 5 hours |
96 |
// and 2004-10-31 04:00 CET - 2004-10-31 00:00 CEST is 5 hours |
79 |
double fraction = (((calStart.get(Calendar.HOUR_OF_DAY) * 60 |
97 |
double fraction = (((date.get(Calendar.HOUR_OF_DAY) * 60 |
80 |
+ calStart.get(Calendar.MINUTE) |
98 |
+ date.get(Calendar.MINUTE) |
81 |
) * 60 + calStart.get(Calendar.SECOND) |
99 |
) * 60 + date.get(Calendar.SECOND) |
82 |
) * 1000 + calStart.get(Calendar.MILLISECOND) |
100 |
) * 1000 + date.get(Calendar.MILLISECOND) |
83 |
) / ( double ) DAY_MILLISECONDS; |
101 |
) / ( double ) DAY_MILLISECONDS; |
84 |
calStart = dayStart(calStart); |
102 |
date = dayStart(date); |
85 |
|
103 |
|
86 |
return fraction + ( double ) absoluteDay(calStart) |
104 |
return fraction + ( double ) absoluteDay(date) |
87 |
- CAL_1900_ABSOLUTE; |
105 |
- CAL_1900_ABSOLUTE; |
88 |
} |
106 |
} |
89 |
} |
107 |
} |