/** * Returns the hour of this Timestamp, in its local time. * * @return * a number within the range [0, 23], in its local time; * 0 is returned if the Timestamp isn't * precise to the hour */ public int getHour() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted.getZHour(); }
/** * Returns the year of this Timestamp, in its local time. * * @return * a number within the range [1, 9999], in its local time */ public int getYear() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted.getZYear(); }
/** * Returns the month of this Timestamp, in its local time. * * @return * a number within the range [1, 12], whereby 1 refers to January * and 12 refers to December, in its local time; * 1 is returned if the Timestamp isn't precise to * the month */ public int getMonth() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted.getZMonth(); }
/** * Returns the day (within the month) of this Timestamp, in its local time. * * @return * a number within the range [1, 31], in its local time; * 1 is returned if the Timestamp isn't * precise to the day */ public int getDay() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted.getZDay(); }
/** * Returns the minute of this Timestamp, in its local time. * * @return * a number within the range [0, 59], in its local time; * 0 is returned if the Timestamp isn't * precise to the minute */ public int getMinute() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted.getZMinute(); }
/** * Prints to an {@code Appendable} the string representation (in Ion format) * of this Timestamp in its local time. * <p> * This method produces the same output as {@link #toString()}. * * @param out not {@code null} * * @throws IOException propagated when the {@link Appendable} throws it * * @see #printZ(Appendable) */ public void print(Appendable out) throws IOException { // we have to make a copy to preserve the "immutable" contract // on Timestamp and we don't want someone reading the calendar // member while we've shifted it around. Timestamp adjusted = this; // Adjust UTC time back to local time if (this._offset != null && this._offset.intValue() != 0) { adjusted = make_localtime(); } print(out, adjusted); }
/** * Adds the given amount to the given {@link Calendar} field and returns a new Timestamp * with precision set to the maximum of the current precision and the given precision. * @param field the field. * @param amount an amount. * @param precision the precision corresponding to the given field. * @return a new Timestamp instance. */ private Timestamp calendarAdd(int field, int amount, Precision precision) { if (amount == 0 && _precision == precision) return this; Timestamp timestamp = make_localtime(); timestamp._calendar.add(field, amount); checkCalendarYear(timestamp._calendar); if (_offset != null) { timestamp.apply_offset(_offset); timestamp._offset = _offset; } timestamp._precision = _precision.includes(precision) ? timestamp._precision : precision; return timestamp; }
/** * Returns the year of this Timestamp, in its local time. * * @return * a number within the range [1, 9999], in its local time */ public int getYear() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._year; }
/** * Returns the hour of this Timestamp, in its local time. * * @return * a number within the range [0, 23], in its local time; * 0 is returned if the Timestamp isn't * precise to the hour */ public int getHour() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._hour; }
/** * Returns the year of this Timestamp, in its local time. * * @return * a number within the range [1, 9999], in its local time */ public int getYear() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._year; }
/** * Returns the month of this Timestamp, in its local time. * * @return * a number within the range [1, 12], whereby 1 refers to January * and 12 refers to December, in its local time; * 1 is returned if the Timestamp isn't precise to * the month */ public int getMonth() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._month; }
/** * Returns the day (within the month) of this Timestamp, in its local time. * * @return * a number within the range [1, 31], in its local time; * 1 is returned if the Timestamp isn't * precise to the day */ public int getDay() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._day; }
/** * Returns the minute of this Timestamp, in its local time. * * @return * a number within the range [0, 59], in its local time; * 0 is returned if the Timestamp isn't * precise to the minute */ public int getMinute() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._minute; }
/** * Returns the month of this Timestamp, in its local time. * * @return * a number within the range [1, 12], whereby 1 refers to January * and 12 refers to December, in its local time; * 1 is returned if the Timestamp isn't precise to * the month */ public int getMonth() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._month; }
/** * Returns the day (within the month) of this Timestamp, in its local time. * * @return * a number within the range [1, 31], in its local time; * 1 is returned if the Timestamp isn't * precise to the day */ public int getDay() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._day; }
/** * Returns the hour of this Timestamp, in its local time. * * @return * a number within the range [0, 23], in its local time; * 0 is returned if the Timestamp isn't * precise to the hour */ public int getHour() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._hour; }
/** * Returns the minute of this Timestamp, in its local time. * * @return * a number within the range [0, 59], in its local time; * 0 is returned if the Timestamp isn't * precise to the minute */ public int getMinute() { Timestamp adjusted = this; if (this._offset != null) { if (this._offset.intValue() != 0) { adjusted = make_localtime(); } } return adjusted._minute; }
/** * Prints to an {@code Appendable} the string representation (in Ion format) * of this Timestamp in its local time. * <p> * This method produces the same output as {@link #toString()}. * * @param out not {@code null} * * @throws IOException propagated when the {@link Appendable} throws it * * @see #printZ(Appendable) */ public void print(Appendable out) throws IOException { // we have to make a copy to preserve the "immutable" contract // on Timestamp and we don't want someone reading the calendar // member while we've shifted it around. Timestamp adjusted = this; // Adjust UTC time back to local time if (this._offset != null && this._offset.intValue() != 0) { adjusted = make_localtime(); } print(out, adjusted); }
/** * Returns a timestamp relative to this one by the given number of * milliseconds. * * @param amount a (positive or negative) number of milliseconds. */ public final Timestamp addMillis(long amount) { if (amount == 0) return this; // This strips off the local offset, expressing our fields as if they // were UTC. BigDecimal millis = make_localtime().getDecimalMillis(); millis = millis.add(BigDecimal.valueOf(amount)); Timestamp ts = new Timestamp(millis, _precision, _offset); // Anything with courser-than-millis precision will have been extended // to 3 decimal places due to use of getDecimalMillis(). Fix that. ts._fraction = _fraction; if (_offset != null && _offset != 0) { ts.apply_offset(_offset); } return ts; }
/** * Returns a timestamp relative to this one by the given number of * milliseconds. * * @param amount a (positive or negative) number of milliseconds. */ public final Timestamp addMillis(long amount) { if (amount == 0) return this; // This strips off the local offset, expressing our fields as if they // were UTC. BigDecimal millis = make_localtime().getDecimalMillis(); millis = millis.add(BigDecimal.valueOf(amount)); Timestamp ts = new Timestamp(millis, _precision, _offset); // Anything with courser-than-millis precision will have been extended // to 3 decimal places due to use of getDecimalMillis(). Fix that. ts._fraction = _fraction; if (_offset != null && _offset != 0) { ts.apply_offset(_offset); } return ts; }