Java Code Examples for java.sql.Timestamp#clone()
The following examples show how to use
java.sql.Timestamp#clone() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimeUtil.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
/** * Return a new Timestamp object which value is adjusted according to known DATE, DATETIME or TIMESTAMP field precision. * * @param ts * an original Timestamp object, not modified by this method * @param fsp * value in the range from 0 to 6 specifying fractional seconds precision * @param serverRoundFracSecs * Flag indicating whether rounding or truncation occurs on server when inserting a TIME, DATE, or TIMESTAMP value with a fractional seconds part * into a column having the same type but fewer fractional digits: true means rounding, false means truncation. The proper value should be * detected by analyzing sql_mode server variable for TIME_TRUNCATE_FRACTIONAL presence. * @return A new Timestamp object cloned from original ones and then rounded or truncated according to required fsp value */ public static Timestamp adjustTimestampNanosPrecision(Timestamp ts, int fsp, boolean serverRoundFracSecs) { if (fsp < 0 || fsp > 6) { throw ExceptionFactory.createException(WrongArgumentException.class, "fsp value must be in 0 to 6 range."); } Timestamp res = (Timestamp) ts.clone(); int nanos = res.getNanos(); double tail = Math.pow(10, 9 - fsp); if (serverRoundFracSecs) { nanos = (int) Math.round(nanos / tail) * (int) tail; if (nanos > 999999999) { nanos %= 1000000000; // get only last 9 digits res.setTime(res.getTime() + 1000); // increment seconds } } else { nanos = (int) (nanos / tail) * (int) tail; } res.setNanos(nanos); return res; }
Example 2
Source File: TestPlan.java From testgrid with Apache License 2.0 | 5 votes |
/** * Sets the created timestamp for this test-plan. * * @param createdTimestamp timestamp value to be set */ public void setCreatedTimestamp(Timestamp createdTimestamp) { if (createdTimestamp != null) { this.createdTimestamp = (Timestamp) createdTimestamp.clone(); } }
Example 3
Source File: Suspension.java From StatsAgg with Apache License 2.0 | 5 votes |
public Suspension(Integer id, String name, String uppercaseName, String description, Boolean isEnabled, Integer suspendBy, Integer alertId, String metricGroupTagsInclusive, String metricGroupTagsExclusive, String metricSuspensionRegexes, Boolean isOneTime, Boolean isSuspendNotificationOnly, Boolean isRecurSunday, Boolean isRecurMonday, Boolean isRecurTuesday, Boolean isRecurWednesday, Boolean isRecurThursday, Boolean isRecurFriday, Boolean isRecurSaturday, Timestamp startDate, Timestamp startTime, Long duration, Integer durationTimeUnit, Timestamp deleteAtTimestamp) { this.id_ = id; this.name_ = name; this.uppercaseName_ = uppercaseName; this.description_ = description; this.isEnabled_ = isEnabled; this.suspendBy_ = suspendBy; this.alertId_ = alertId; this.metricGroupTagsInclusive_ = metricGroupTagsInclusive; this.metricGroupTagsExclusive_ = metricGroupTagsExclusive; this.metricSuspensionRegexes_ = metricSuspensionRegexes; this.isOneTime_ = isOneTime; this.isSuspendNotificationOnly_ = isSuspendNotificationOnly; this.isRecurSunday_ = isRecurSunday; this.isRecurMonday_ = isRecurMonday; this.isRecurTuesday_ = isRecurTuesday; this.isRecurWednesday_ = isRecurWednesday; this.isRecurThursday_ = isRecurThursday; this.isRecurFriday_ = isRecurFriday; this.isRecurSaturday_ = isRecurSaturday; if (startDate == null) this.startDate_ = null; else this.startDate_ = (Timestamp) startDate.clone(); if (startTime == null) this.startTime_ = null; else this.startTime_ = (Timestamp) startTime.clone(); this.duration_ = duration; this.durationTimeUnit_ = durationTimeUnit; if (deleteAtTimestamp == null) this.deleteAtTimestamp_ = null; else this.deleteAtTimestamp_ = (Timestamp) deleteAtTimestamp.clone(); }
Example 4
Source File: MetricLastSeen.java From StatsAgg with Apache License 2.0 | 5 votes |
public MetricLastSeen(String metricKeySha1, String metricKey, Timestamp lastModified) { this.metricKeySha1_ = metricKeySha1; this.metricKey_ = metricKey; if (lastModified == null) this.lastModified_ = null; else this.lastModified_ = (Timestamp) lastModified.clone(); }
Example 5
Source File: Gauge.java From StatsAgg with Apache License 2.0 | 5 votes |
public Gauge(String bucketSha1, String bucket, BigDecimal metricValue, Timestamp lastModified) { this.bucketSha1_ = bucketSha1; this.bucket_ = bucket; this.metricValue_ = metricValue; if (lastModified == null) this.lastModified_ = null; else this.lastModified_ = (Timestamp) lastModified.clone(); }
Example 6
Source File: TestPlan.java From testgrid with Apache License 2.0 | 4 votes |
/** * Sets the modified timestamp for this test-plan. * * @param modifiedTimestamp timestamp value to be set */ public void setModifiedTimestamp(Timestamp modifiedTimestamp) { if (modifiedTimestamp != null) { this.modifiedTimestamp = (Timestamp) modifiedTimestamp.clone(); } }
Example 7
Source File: Envelope.java From peer-os with Apache License 2.0 | 4 votes |
public void setCreateDate( final Timestamp createDate ) { this.createDate = ( Timestamp ) createDate.clone(); }
Example 8
Source File: Suspension.java From StatsAgg with Apache License 2.0 | 4 votes |
public void setStartDate(Timestamp startDate) { if (startDate == null) this.startDate_ = null; else this.startDate_ = (Timestamp) startDate.clone(); }
Example 9
Source File: Suspension.java From StatsAgg with Apache License 2.0 | 4 votes |
public void setStartTime(Timestamp startTime) { if (startTime == null) this.startTime_ = null; else this.startTime_ = (Timestamp) startTime.clone(); }
Example 10
Source File: Suspension.java From StatsAgg with Apache License 2.0 | 4 votes |
public void setDeleteAtTimestamp(Timestamp deleteAtTimestamp) { if (deleteAtTimestamp == null) this.deleteAtTimestamp_ = null; else this.deleteAtTimestamp_ = (Timestamp) deleteAtTimestamp.clone(); }
Example 11
Source File: Alert.java From StatsAgg with Apache License 2.0 | 4 votes |
public Alert(Integer id, String name, String uppercaseName, String description, Integer metricGroupId, Boolean isEnabled, Boolean isCautionEnabled, Boolean isDangerEnabled, Integer alertType, Boolean alertOnPositive, Boolean allowResendAlert, Long resendAlertEvery, Integer resendAlertEveryTimeUnit, Integer cautionNotificationGroupId, Integer cautionPositiveNotificationGroupId, Integer cautionOperator, Integer cautionCombination, Integer cautionCombinationCount, BigDecimal cautionThreshold, Long cautionWindowDuration, Integer cautionWindowDurationTimeUnit, Long cautionStopTrackingAfter, Integer cautionStopTrackingAfterTimeUnit, Integer cautionMinimumSampleCount, Boolean isCautionAlertActive, Timestamp cautionAlertLastSentTimestamp, Boolean isCautionAlertAcknowledged, String cautionActiveAlertsSet, Timestamp cautionFirstActiveAt, Integer dangerNotificationGroupId, Integer dangerPositiveNotificationGroupId, Integer dangerOperator, Integer dangerCombination, Integer dangerCombinationCount, BigDecimal dangerThreshold, Long dangerWindowDuration, Integer dangerWindowDurationTimeUnit, Long dangerStopTrackingAfter, Integer dangerStopTrackingAfterTimeUnit, Integer dangerMinimumSampleCount, Boolean isDangerAlertActive, Timestamp dangerAlertLastSentTimestamp, Boolean isDangerAlertAcknowledged, String dangerActiveAlertsSet, Timestamp dangerFirstActiveAt) { this.id_ = id; this.name_ = name; this.uppercaseName_ = uppercaseName; this.description_ = description; this.metricGroupId_ = metricGroupId; this.isEnabled_ = isEnabled; this.isCautionEnabled_ = isCautionEnabled; this.isDangerEnabled_ = isDangerEnabled; this.alertType_ = alertType; this.alertOnPositive_ = alertOnPositive; this.allowResendAlert_ = allowResendAlert; this.resendAlertEvery_ = resendAlertEvery; this.resendAlertEveryTimeUnit_ = resendAlertEveryTimeUnit; this.cautionNotificationGroupId_ = cautionNotificationGroupId; this.cautionPositiveNotificationGroupId_ = cautionPositiveNotificationGroupId; this.cautionOperator_ = cautionOperator; this.cautionCombination_ = cautionCombination; this.cautionCombinationCount_ = cautionCombinationCount; this.cautionThreshold_ = cautionThreshold; this.cautionWindowDuration_ = cautionWindowDuration; this.cautionWindowDurationTimeUnit_ = cautionWindowDurationTimeUnit; this.cautionStopTrackingAfter_ = cautionStopTrackingAfter; this.cautionStopTrackingAfterTimeUnit_ = cautionStopTrackingAfterTimeUnit; this.cautionMinimumSampleCount_ = cautionMinimumSampleCount; this.isCautionAlertActive_ = isCautionAlertActive; if (cautionAlertLastSentTimestamp == null) this.cautionAlertLastSentTimestamp_ = null; else this.cautionAlertLastSentTimestamp_ = (Timestamp) cautionAlertLastSentTimestamp.clone(); this.isCautionAlertAcknowledged_ = isCautionAlertAcknowledged; this.cautionActiveAlertsSet_ = cautionActiveAlertsSet; this.cautionFirstActiveAt_ = cautionFirstActiveAt; this.dangerNotificationGroupId_ = dangerNotificationGroupId; this.dangerPositiveNotificationGroupId_ = dangerPositiveNotificationGroupId; this.dangerOperator_ = dangerOperator; this.dangerCombination_ = dangerCombination; this.dangerCombinationCount_ = dangerCombinationCount; this.dangerThreshold_ = dangerThreshold; this.dangerWindowDuration_ = dangerWindowDuration; this.dangerWindowDurationTimeUnit_ = dangerWindowDurationTimeUnit; this.dangerStopTrackingAfter_ = dangerStopTrackingAfter; this.dangerStopTrackingAfterTimeUnit_ = dangerStopTrackingAfterTimeUnit; this.dangerMinimumSampleCount_ = dangerMinimumSampleCount; this.isDangerAlertActive_ = isDangerAlertActive; if (dangerAlertLastSentTimestamp == null) this.dangerAlertLastSentTimestamp_ = null; else this.dangerAlertLastSentTimestamp_ = (Timestamp) dangerAlertLastSentTimestamp.clone(); this.isDangerAlertAcknowledged_ = isDangerAlertAcknowledged; this.dangerActiveAlertsSet_ = dangerActiveAlertsSet; this.dangerFirstActiveAt_ = dangerFirstActiveAt; }
Example 12
Source File: Alert.java From StatsAgg with Apache License 2.0 | 4 votes |
public void setCautionAlertLastSentTimestamp(Timestamp cautionAlertLastSentTimestamp) { if (cautionAlertLastSentTimestamp == null) this.cautionAlertLastSentTimestamp_ = null; else this.cautionAlertLastSentTimestamp_ = (Timestamp) cautionAlertLastSentTimestamp.clone(); }
Example 13
Source File: Alert.java From StatsAgg with Apache License 2.0 | 4 votes |
public void setCautionFirstActiveAt(Timestamp cautionFirstActiveAt) { if (cautionFirstActiveAt == null) this.cautionFirstActiveAt_ = null; else this.cautionFirstActiveAt_ = (Timestamp) cautionFirstActiveAt.clone(); }
Example 14
Source File: Alert.java From StatsAgg with Apache License 2.0 | 4 votes |
public void setDangerAlertLastSentTimestamp(Timestamp dangerAlertLastSentTimestamp) { if (dangerAlertLastSentTimestamp == null) this.dangerAlertLastSentTimestamp_ = null; else this.dangerAlertLastSentTimestamp_ = (Timestamp) dangerAlertLastSentTimestamp.clone(); }
Example 15
Source File: Alert.java From StatsAgg with Apache License 2.0 | 4 votes |
public void setDangerFirstActiveAt(Timestamp dangerFirstActiveAt) { if (dangerFirstActiveAt == null) this.dangerFirstActiveAt_ = null; else this.dangerFirstActiveAt_ = (Timestamp) dangerFirstActiveAt.clone(); }
Example 16
Source File: AbstractDBCommand.java From marauroa with GNU General Public License v2.0 | 2 votes |
/** * sets the timestamp when this command was added to the queue * * @param enqueueTime Timestamp */ public void setEnqueueTime(Timestamp enqueueTime) { this.enqueueTime = (Timestamp) enqueueTime.clone(); }