public Object clone() { DateTimeData dt = new DateTimeData( this.year, this.month, this.day, this.hour, this.minute, this.second, this.utc, this.originalValue, this.normalized, this.type); dt.canonical = this.canonical; dt.position = position; dt.timezoneHr = this.timezoneHr; dt.timezoneMin = this.timezoneMin; dt.unNormYear = this.unNormYear; dt.unNormMonth = this.unNormMonth; dt.unNormDay = this.unNormDay; dt.unNormHour = this.unNormHour; dt.unNormMinute = this.unNormMinute; dt.unNormSecond = this.unNormSecond; return dt; }
/** * Parses time zone: 'Z' or {+,-} followed by hh:mm * * @param data * @param sign * @exception RuntimeException */ protected void getTimeZone(String buffer, DateTimeData data, int sign, int end) throws RuntimeException { data.utc = buffer.charAt(sign); if (buffer.charAt(sign) == 'Z') { if (end > (++sign)) { throw new RuntimeException("Error in parsing time zone"); } return; } if (sign <= (end - 6)) { int negate = buffer.charAt(sign) == '-' ? -1 : 1; // parse hr int stop = ++sign + 2; data.timezoneHr = negate * parseInt(buffer, sign, stop); if (buffer.charAt(stop++) != ':') { throw new RuntimeException("Error in parsing time zone"); } // parse min data.timezoneMin = negate * parseInt(buffer, stop, stop + 2); if (stop + 2 != end) { throw new RuntimeException("Error in parsing time zone"); } if (data.timezoneHr != 0 || data.timezoneMin != 0) data.normalized = false; } else { throw new RuntimeException("Error in parsing time zone"); } if (DEBUG) { System.out.println("time[hh]=" + data.timezoneHr + " time[mm]=" + data.timezoneMin); } }
private void cloneDate(DateTimeData finalValue, DateTimeData tempDate) { tempDate.year = finalValue.year; tempDate.month = finalValue.month; tempDate.day = finalValue.day; tempDate.hour = finalValue.hour; tempDate.minute = finalValue.minute; tempDate.second = finalValue.second; tempDate.utc = finalValue.utc; tempDate.timezoneHr = finalValue.timezoneHr; tempDate.timezoneMin = finalValue.timezoneMin; }
/** * Resets object representation of date/time * * @param data date/time object */ protected void resetDateObj(DateTimeData data) { data.year = 0; data.month = 0; data.day = 0; data.hour = 0; data.minute = 0; data.second = 0; data.utc = 0; data.timezoneHr = 0; data.timezoneMin = 0; }
/** * Compare algorithm described in dateDime (3.2.7). Duration datatype overwrites this method * * @param date1 normalized date representation of the first value * @param date2 normalized date representation of the second value * @param strict * @return less, greater, less_equal, greater_equal, equal */ protected short compareDates(DateTimeData date1, DateTimeData date2, boolean strict) { if (date1.utc == date2.utc) { return compareOrder(date1, date2); } short c1, c2; DateTimeData tempDate = new DateTimeData(null, this); if (date1.utc == 'Z') { // compare date1<=date1<=(date2 with time zone -14) // cloneDate(date2, tempDate); // clones date1 value to global temporary storage: fTempDate tempDate.timezoneHr = 14; tempDate.timezoneMin = 0; tempDate.utc = '+'; normalize(tempDate); c1 = compareOrder(date1, tempDate); if (c1 == LESS_THAN) return c1; // compare date1>=(date2 with time zone +14) // cloneDate(date2, tempDate); // clones date1 value to global temporary storage: tempDate tempDate.timezoneHr = -14; tempDate.timezoneMin = 0; tempDate.utc = '-'; normalize(tempDate); c2 = compareOrder(date1, tempDate); if (c2 == GREATER_THAN) return c2; return INDETERMINATE; } else if (date2.utc == 'Z') { // compare (date1 with time zone -14)<=date2 // cloneDate(date1, tempDate); // clones date1 value to global temporary storage: tempDate tempDate.timezoneHr = -14; tempDate.timezoneMin = 0; tempDate.utc = '-'; if (DEBUG) { System.out.println("tempDate=" + dateToString(tempDate)); } normalize(tempDate); c1 = compareOrder(tempDate, date2); if (DEBUG) { System.out.println("date=" + dateToString(date2)); System.out.println("tempDate=" + dateToString(tempDate)); } if (c1 == LESS_THAN) return c1; // compare (date1 with time zone +14)<=date2 // cloneDate(date1, tempDate); // clones date1 value to global temporary storage: tempDate tempDate.timezoneHr = 14; tempDate.timezoneMin = 0; tempDate.utc = '+'; normalize(tempDate); c2 = compareOrder(tempDate, date2); if (DEBUG) { System.out.println("tempDate=" + dateToString(tempDate)); } if (c2 == GREATER_THAN) return c2; return INDETERMINATE; } return INDETERMINATE; }