java.util.Date.clone()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(247)

本文整理了Java中java.util.Date.clone()方法的一些代码示例,展示了Date.clone()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.clone()方法的具体详情如下:
包路径:java.util.Date
类名称:Date
方法名:clone

Date.clone介绍

[英]Returns a new Date with the same millisecond value as this Date.
[中]返回与此日期具有相同毫秒值的新日期。

代码示例

代码示例来源:origin: apache/zookeeper

public Date getEstablished() {
  return (Date)established.clone();
}

代码示例来源:origin: oracle/opengrok

public final void setDate(Date date) {
  if (date == null) {
    this.date = null;
  } else {
    this.date = (Date) date.clone();
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the time for which the validation of the certification path
 * should be evaluated.
 *
 * @return the time for the validation, or {@code null} for the current
 *         time.
 */
public Date getDate() {
  return date == null ? null : (Date)date.clone();
}

代码示例来源:origin: robovm/robovm

/**
 * Sets the criterion for the validity date of the certificate.
 * <p>
 * The certificate must be valid at the specified date.
 * @param certificateValid
 *            the validity date or {@code null} to not check the date.
 */
public void setCertificateValid(Date certificateValid) {
  this.certificateValid = (certificateValid == null)
              ? null
              : (Date) certificateValid.clone();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the criterion for the validity date of the certificate.
 *
 * @return the validity date or {@code null} if the date is not to be
 *         checked.
 */
public Date getCertificateValid() {
  return (certificateValid == null)
              ? null
              : (Date) certificateValid.clone();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the date which is the start of the one hundred year period for two-digit year values.
 * See {@link #set2DigitYearStart} for details.
 */
public Date get2DigitYearStart() {
  return (Date) defaultCenturyStart.clone();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the date and time of this {@code Timestamp}.
 *
 * @return the date and time of this {@code Timestamp}.
 */
public Date getTimestamp() {
  return (Date) timestamp.clone();
}

代码示例来源:origin: oracle/opengrok

public Date getDate() {
  return (date == null) ? null : (Date) date.clone();
}

代码示例来源:origin: shopizer-ecommerce/shopizer

public static Date clone(Date date) {
  if (date != null) {
    return (Date) date.clone();
  }
  return null;
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the criterion for the validity date of the private key.
 * <p>
 * The private key must be valid at the specified date.
 *
 * @return the validity date or {@code null} if the date is not to be
 *         checked.
 */
public Date getPrivateKeyValid() {
  if (privateKeyValid != null) {
    return (Date) privateKeyValid.clone();
  }
  return null;
}

代码示例来源:origin: robovm/robovm

/**
 * Sets the criterion for the validity date of the private key.
 * <p>
 * The private key must be valid at the specified date.
 *
 * @param privateKeyValid
 *            the validity date or {@code null} to not check the date.
 */
public void setPrivateKeyValid(Date privateKeyValid) {
  if (privateKeyValid == null) {
    this.privateKeyValid = null;
    return;
  }
  this.privateKeyValid = (Date) privateKeyValid.clone();
}

代码示例来源:origin: ZHENFENG13/My-Blog

public static Date nextDay(Date date) {
  Date newDate = (Date)date.clone();
  long time = newDate.getTime() / 1000L + 86400L;
  newDate.setTime(time * 1000L);
  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  try {
    newDate = format.parse(format.format(newDate));
  } catch (Exception var6) {
    System.out.println(var6.getMessage());
  }
  return newDate;
}

代码示例来源:origin: ZHENFENG13/My-Blog

public static Date getWeekAgo(Date date) {
  Date newDate = (Date)date.clone();
  long time = newDate.getTime() / 1000L - 604800L;
  newDate.setTime(time * 1000L);
  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  try {
    newDate = format.parse(format.format(newDate));
  } catch (Exception var6) {
    System.out.println(var6.getMessage());
  }
  return newDate;
}

代码示例来源:origin: ZHENFENG13/My-Blog

public static Date yesterday(Date date) {
  Date newDate = (Date)date.clone();
  long time = newDate.getTime() / 1000L - 86400L;
  newDate.setTime(time * 1000L);
  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  try {
    newDate = format.parse(format.format(newDate));
  } catch (Exception var6) {
    System.out.println(var6.getMessage());
  }
  return newDate;
}

代码示例来源:origin: spring-projects/spring-batch

public Date getVarDate() {
  return (Date) varDate.clone();
}

代码示例来源:origin: org.codehaus.groovy/groovy

@Deprecated
public static void downto(Date self, Date to, Closure closure) {
  if (self.compareTo(to) >= 0) {
    for (Date i = (Date) self.clone(); i.compareTo(to) >= 0; i = previous(i)) {
      closure.call(i);
    }
  } else
    throw new GroovyRuntimeException("The argument (" + to +
        ") to downto() cannot be later than the value (" + self + ") it's called on.");
}

代码示例来源:origin: org.codehaus.groovy/groovy

@Deprecated
public static void upto(Date self, Date to, Closure closure) {
  if (self.compareTo(to) <= 0) {
    for (Date i = (Date) self.clone(); i.compareTo(to) <= 0; i = next(i)) {
      closure.call(i);
    }
  } else
    throw new GroovyRuntimeException("The argument (" + to +
        ") to upto() cannot be earlier than the value (" + self + ") it's called on.");
}

代码示例来源:origin: citerus/dddsample-core

/**
 * @param origin origin location - can't be the same as the destination
 * @param destination destination location - can't be the same as the origin
 * @param arrivalDeadline arrival deadline
 */
public RouteSpecification(final Location origin, final Location destination, final Date arrivalDeadline) {
 Validate.notNull(origin, "Origin is required");
 Validate.notNull(destination, "Destination is required");
 Validate.notNull(arrivalDeadline, "Arrival deadline is required");
 Validate.isTrue(!origin.sameIdentityAs(destination), "Origin and destination can't be the same: " + origin);
 this.origin = origin;
 this.destination = destination;
 this.arrivalDeadline = (Date) arrivalDeadline.clone();
}

代码示例来源:origin: querydsl/querydsl

@SuppressWarnings("unchecked")
public DateConstant(D date) {
  super(ConstantImpl.create(date));
  this.date = (D) date.clone();
  this.calendar = Calendar.getInstance();
  calendar.setTime(date);
}

代码示例来源:origin: querydsl/querydsl

@SuppressWarnings("unchecked")
public TimeConstant(D time) {
  super(ConstantImpl.create(time));
  this.calendar = Calendar.getInstance();
  this.time = (D) time.clone();
  calendar.setTime(time);
}

相关文章