* bug augmenting the End date
* by a day
*/
long oneDay = 0;//bug 1189
StaticDataHelper sdh = new StaticDataHelper();
String osVersion = sdh.getOS();
if (list.isSupportedField(field)) {
try {
value = event.getDate(field, 0);
StaticDataHelper.log("[LOG]Retrieving from device date to add to SIF-E: "
+ new Date(value).toString() + "[" + value + "]");
} catch (Exception e) {
StaticDataHelper.log(">>>Exception in XMLEventParser.appendFieldDate() "
+ "--> Field not set: " + tag + " e.toString(): "
+ e.toString());
}
//a Calendar in GMT
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));//getInstance()
//the date in the local time zone
Date evdate = new Date(value);
//the offset of the local time zone
offset = getTimeZoneOffSet(evdate);
//the calendar receives the local date as it was GMT
cal.setTime(new Date(value - offset));
// If the year is 1970, It can be to fix, check the cache.
if (cal.get(cal.YEAR) <= 1970) {
/*
* this check is to fix a bug introduced
* with the caching feature. In fact, the
* object cacheData is initialized only
* in the method parseEvent(), that is
* invoked only on data coming from the
* server to the client. When data is
* transferred only from the client to
* the server, the variable is not
* initialized, and a NullPointerException
* is thrown
*/
if (cacheData != null) {
Long cd = (Long)cacheData.get(tag);
if (cd != null) {
long cached = cd.longValue();
if (cached < 0) {
// Restore the original date prior to 01/01/1970
value = cached;
evdate = new Date(value);
cal.setTime(evdate);
}
}
}
}
if (allday) {
format = DATETIME_FORMAT_ALLDAY;//"yyyy-MM-dd"
// If it's an end date and it's past 01/01/1970,
// check if it has to be fixed.
if (isBuggy("allday") && tag.equals(END) && value > 0) { //allday <End>
long start = event.getDate(event.START, event.ATTR_NONE);
StaticDataHelper.log("[LOG]'value' -> " + new Date(value).toString());
StaticDataHelper.log("[LOG]'start' -> " + new Date(start).toString());
// If the event is changed, or it is new, we must fix
// the end before sending it out.
if (isEventChanged(start, value)) {//'value' is here the end date
oneDay = 24*60*60*1000;
}
}
} else {//not allday
format = DATETIME_FORMAT_UTC;//"yyyyMMdd'T'HHmmss'Z'"
}
SimpleDateFormat formatter = new SimpleDateFormat(format);
// FIXME: why cal.getTime().getTime() should be different from value?
sdh.log(">>>original date: " + new Date(cal.getTime().getTime()).toString());
formattedDate = formatter.format( new Date(cal.getTime().getTime() - oneDay) );
sdh.log(">>>fixed date: " + formattedDate);
/*
* this is to use the start date
* information of the <Start>
* element as content for the not supported