下面列出了java.sql.Timestamp#clone ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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;
}
/**
* 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();
}
}
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();
}
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();
}
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();
}
/**
* 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();
}
}
public void setCreateDate( final Timestamp createDate )
{
this.createDate = ( Timestamp ) createDate.clone();
}
public void setStartDate(Timestamp startDate) {
if (startDate == null) this.startDate_ = null;
else this.startDate_ = (Timestamp) startDate.clone();
}
public void setStartTime(Timestamp startTime) {
if (startTime == null) this.startTime_ = null;
else this.startTime_ = (Timestamp) startTime.clone();
}
public void setDeleteAtTimestamp(Timestamp deleteAtTimestamp) {
if (deleteAtTimestamp == null) this.deleteAtTimestamp_ = null;
else this.deleteAtTimestamp_ = (Timestamp) deleteAtTimestamp.clone();
}
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;
}
public void setCautionAlertLastSentTimestamp(Timestamp cautionAlertLastSentTimestamp) {
if (cautionAlertLastSentTimestamp == null) this.cautionAlertLastSentTimestamp_ = null;
else this.cautionAlertLastSentTimestamp_ = (Timestamp) cautionAlertLastSentTimestamp.clone();
}
public void setCautionFirstActiveAt(Timestamp cautionFirstActiveAt) {
if (cautionFirstActiveAt == null) this.cautionFirstActiveAt_ = null;
else this.cautionFirstActiveAt_ = (Timestamp) cautionFirstActiveAt.clone();
}
public void setDangerAlertLastSentTimestamp(Timestamp dangerAlertLastSentTimestamp) {
if (dangerAlertLastSentTimestamp == null) this.dangerAlertLastSentTimestamp_ = null;
else this.dangerAlertLastSentTimestamp_ = (Timestamp) dangerAlertLastSentTimestamp.clone();
}
public void setDangerFirstActiveAt(Timestamp dangerFirstActiveAt) {
if (dangerFirstActiveAt == null) this.dangerFirstActiveAt_ = null;
else this.dangerFirstActiveAt_ = (Timestamp) dangerFirstActiveAt.clone();
}
/**
* sets the timestamp when this command was added to the queue
*
* @param enqueueTime Timestamp
*/
public void setEnqueueTime(Timestamp enqueueTime) {
this.enqueueTime = (Timestamp) enqueueTime.clone();
}