/** * Converts the value of this Timestamp into a {@link Date}, * representing the time in UTC. * <p> * This method will return the same result for all Timestamps representing * the same point in time, regardless of the local offset. * <p> * Because {@link Date} instances are mutable, this method returns a * new instance from each call. * * @return a new {@code Date} instance, in UTC */ public Date dateValue() { long millis = getMillis(); return new Date(millis); }
public long getMillis() { if (_isNullValue()) { throw new NullValueException(); } return _timestamp_value.getMillis(); }
private final void fn_from_string_to_date() { if (!hasValueOfType(AS_TYPE.timestamp_value)) { fn_from_string_to_timestamp(); } _date_value = new Date(_timestamp_value.getMillis()); add_value_type(AS_TYPE.date_value); } private final void fn_from_string_to_timestamp() {
public void writeTimestamp(Timestamp value) throws IOException { if (value == null) { writeNull(IonType.TIMESTAMP); return; } startValue(); if (_options._timestamp_as_millis) { long millis = value.getMillis(); _output.appendAscii(Long.toString(millis)); } else if (_options._timestamp_as_string) { // Timestamp is ASCII-safe so this is easy _output.appendAscii('"'); _output.appendAscii(value.toString()); _output.appendAscii('"'); } else { _output.appendAscii(value.toString()); } closeValue(); }
/** * Converts the value of this Timestamp into a {@link Date}, * representing the time in UTC. * <p> * This method will return the same result for all Timestamps representing * the same point in time, regardless of the local offset. * <p> * Because {@link Date} instances are mutable, this method returns a * new instance from each call. * * @return a new {@code Date} instance, in UTC */ public Date dateValue() { long millis = getMillis(); return new Date(millis); }
/** * Converts the value of this Timestamp into a {@link Date}, * representing the time in UTC. * <p> * This method will return the same result for all Timestamps representing * the same point in time, regardless of the local offset. * <p> * Because {@link Date} instances are mutable, this method returns a * new instance from each call. * * @return a new {@code Date} instance, in UTC */ public Date dateValue() { long millis = getMillis(); return new Date(millis); }
/** * Converts the value of this Timestamp as a {@link Calendar}, in its * local time. * <p> * Because {@link Calendar} instances are mutable, this method returns a * new instance from each call. * * @return a new {@code Calendar} instance, in its local time. * */ public Calendar calendarValue() { Calendar cal = new GregorianCalendar(PrivateUtils.UTC); long millis = getMillis(); Integer offset = _offset; if (offset != null && offset != 0) { int offsetMillis = offset * 60 * 1000; millis += offsetMillis; cal.setTimeInMillis(millis); // Resets the offset! cal.set(Calendar.ZONE_OFFSET, offsetMillis); } else { cal.setTimeInMillis(millis); } return cal; }
/** * Converts the value of this Timestamp as a {@link Calendar}, in its * local time. * <p> * Because {@link Calendar} instances are mutable, this method returns a * new instance from each call. * * @return a new {@code Calendar} instance, in its local time. * */ public Calendar calendarValue() { Calendar cal = new GregorianCalendar(PrivateUtils.UTC); long millis = getMillis(); Integer offset = _offset; if (offset != null && offset != 0) { int offsetMillis = offset * 60 * 1000; millis += offsetMillis; cal.setTimeInMillis(millis); // Resets the offset! cal.set(Calendar.ZONE_OFFSET, offsetMillis); } else { cal.setTimeInMillis(millis); } return cal; }
public long getMillis() { if (_isNullValue()) { throw new NullValueException(); } return _timestamp_value.getMillis(); }
public long getMillis() { if (_isNullValue()) { throw new NullValueException(); } return _timestamp_value.getMillis(); }
private final void fn_from_string_to_date() { if (!hasValueOfType(AS_TYPE.timestamp_value)) { fn_from_string_to_timestamp(); } _date_value = new Date(_timestamp_value.getMillis()); add_value_type(AS_TYPE.date_value); } private final void fn_from_string_to_timestamp() {
private final void fn_from_string_to_date() { if (!hasValueOfType(AS_TYPE.timestamp_value)) { fn_from_string_to_timestamp(); } _date_value = new Date(_timestamp_value.getMillis()); add_value_type(AS_TYPE.date_value); } private final void fn_from_string_to_timestamp() {
public void writeTimestamp(Timestamp value) throws IOException { if (value == null) { writeNull(IonType.TIMESTAMP); return; } startValue(); if (_options._timestamp_as_millis) { long millis = value.getMillis(); _output.appendAscii(Long.toString(millis)); } else if (_options._timestamp_as_string) { // Timestamp is ASCII-safe so this is easy _output.appendAscii('"'); _output.appendAscii(value.toString()); _output.appendAscii('"'); } else { _output.appendAscii(value.toString()); } closeValue(); }
public void writeTimestamp(Timestamp value) throws IOException { if (value == null) { writeNull(IonType.TIMESTAMP); return; } startValue(); if (_options._timestamp_as_millis) { long millis = value.getMillis(); _output.appendAscii(Long.toString(millis)); } else if (_options._timestamp_as_string) { // Timestamp is ASCII-safe so this is easy _output.appendAscii('"'); _output.appendAscii(value.toString()); _output.appendAscii('"'); } else { _output.appendAscii(value.toString()); } closeValue(); }