Java Code Examples for java.util.Date.clone()

The following are Jave code examples for showing how to use clone() of the java.util.Date class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: continuous-performance-evaluation   File: HandlingEvent.java   View Source Code Vote up 6 votes
/**
 * @param cargo The cargo
 * @param completionTime completion time, the reported time that the event
 * actually happened (e.g. the receive took place).
 * @param registrationTime registration time, the time the message is
 * received
 * @param type type of event
 * @param location where the event took place
 * @param voyage the voyage
 */
public HandlingEvent(Cargo cargo, Date completionTime,
        Date registrationTime, Type type, Location location, Voyage voyage) {
    Validate.notNull(cargo, "Cargo is required");
    Validate.notNull(completionTime, "Completion time is required");
    Validate.notNull(registrationTime, "Registration time is required");
    Validate.notNull(type, "Handling event type is required");
    Validate.notNull(location, "Location is required");
    Validate.notNull(voyage, "Voyage is required");

    if (type.prohibitsVoyage()) {
        throw new IllegalArgumentException(
                "Voyage is not allowed with event type " + type);
    }

    this.voyage = voyage;
    this.completionTime = (Date) completionTime.clone();
    this.registrationTime = (Date) registrationTime.clone();
    this.type = type;
    this.location = location;
    this.cargo = cargo;
    this.id=(long)(Math.random()*Long.MAX_VALUE);
}
 
Example 2
Project: Hands-On-Android-UI-Development   File: DatePickerWrapper.java   View Source Code Vote up 6 votes
public void setDate(final Date date) {
    if (date == null) {
        throw new IllegalArgumentException("date may not be null");
    }

    this.currentDate = (Date) date.clone();
    this.display.setText(dateFormat.format(currentDate));

    if (this.dialog != null) {
        final GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(getDate());

        this.dialog.updateDate(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH)
        );
    }
}
 
Example 3
Project: Hands-On-Android-UI-Development   File: DatePickerWrapper.java   View Source Code Vote up 6 votes
public void setDate(final Date date) {
    if (date == null) {
        throw new IllegalArgumentException("date may not be null");
    }

    this.currentDate = (Date) date.clone();
    this.display.setText(dateFormat.format(currentDate));

    if (this.dialog != null) {
        final GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(getDate());

        this.dialog.updateDate(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH)
        );
    }
}
 
Example 4
Project: Hands-On-Android-UI-Development   File: DatePickerWrapper.java   View Source Code Vote up 6 votes
public void setDate(final Date date) {
    if (date == null) {
        throw new IllegalArgumentException("date may not be null");
    }

    this.currentDate = (Date) date.clone();
    this.display.setText(dateFormat.format(currentDate));

    if (this.dialog != null) {
        final GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(getDate());

        this.dialog.updateDate(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH)
        );
    }
}
 
Example 5
Project: Hands-On-Android-UI-Development   File: DatePickerWrapper.java   View Source Code Vote up 6 votes
public void setDate(final Date date) {
    if (date == null) {
        throw new IllegalArgumentException("date may not be null");
    }

    this.currentDate = (Date) date.clone();
    this.display.setText(dateFormat.format(currentDate));

    if (this.dialog != null) {
        final GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(getDate());

        this.dialog.updateDate(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH)
        );
    }
}
 
Example 6
Project: Equella   File: DeactivateOperation.java   View Source Code Vote up 6 votes
@Override
protected boolean doOperation(ActivateRequest request, ActivateRequestDao dao)
{
	Date now = params.getDateNow();

	if( request.getUntil().after(now) && request.getStatus() == ActivateRequest.TYPE_ACTIVE )
	{
		Date cancellationDate = (Date) now.clone();

		// Just before 'from'/'now': Don't want crossover!
		cancellationDate.setTime(cancellationDate.getTime() - 1);

		request.setStatus(ActivateRequest.TYPE_INACTIVE);
		request.setUntil(cancellationDate);
		dao.update(request);
	}
	return true;
}
 
Example 7
Project: Hands-On-Android-UI-Development   File: DatePickerWrapper.java   View Source Code Vote up 6 votes
public void setDate(final Date date) {
    if (date == null) {
        throw new IllegalArgumentException("date may not be null");
    }

    this.currentDate = (Date) date.clone();
    this.display.setText(dateFormat.format(currentDate));

    if (this.dialog != null) {
        final GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(getDate());

        this.dialog.updateDate(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH)
        );
    }
}
 
Example 8
Project: living-documentation   File: HandlingEvent.java   View Source Code Vote up 6 votes
/**
 * @param cargo            cargo
 * @param completionTime   completion time, the reported time that the event actually happened (e.g. the receive took place).
 * @param registrationTime registration time, the time the message is received
 * @param type             type of event
 * @param location         where the event took place
 */
public HandlingEvent(final Cargo cargo,
                     final Date completionTime,
                     final Date registrationTime,
                     final HandlingEventType type,
                     final Location location) {
    Validate.notNull(cargo, "Cargo is required");
    Validate.notNull(completionTime, "Completion time is required");
    Validate.notNull(registrationTime, "Registration time is required");
    Validate.notNull(type, "Handling event type is required");
    Validate.notNull(location, "Location is required");

    if (type.requiresVoyage()) {
        throw new IllegalArgumentException("Voyage is required for event type " + type);
    }

    this.completionTime = (Date) completionTime.clone();
    this.registrationTime = (Date) registrationTime.clone();
    this.type = type;
    this.location = location;
    this.cargo = cargo;
    this.voyage = null;
}
 
Example 9
Project: living-documentation   File: HandlingEvent.java   View Source Code Vote up 6 votes
/**
 * @param cargo            cargo
 * @param completionTime   completion time, the reported time that the event actually happened (e.g. the receive took place).
 * @param registrationTime registration time, the time the message is received
 * @param type             type of event
 * @param location         where the event took place
 * @param voyage           the voyage
 */
public HandlingEvent(final Cargo cargo,
                     final Date completionTime,
                     final Date registrationTime,
                     final HandlingEventType type,
                     final Location location,
                     final Voyage voyage) {
    Validate.notNull(cargo, "Cargo is required");
    Validate.notNull(completionTime, "Completion time is required");
    Validate.notNull(registrationTime, "Registration time is required");
    Validate.notNull(type, "Handling event type is required");
    Validate.notNull(location, "Location is required");
    Validate.notNull(voyage, "Voyage is required");

    if (type.prohibitsVoyage()) {
        throw new IllegalArgumentException("Voyage is not allowed with event type " + type);
    }

    this.voyage = voyage;
    this.completionTime = (Date) completionTime.clone();
    this.registrationTime = (Date) registrationTime.clone();
    this.type = type;
    this.location = location;
    this.cargo = cargo;
}
 
Example 10
Project: MonitorPlatform   File: RedisConfig.java   View Source Code Vote up 5 votes
/**
 * 
 * @param startTime 开始时间
 */
public void setStartTime(final Date startTime) {
    if(startTime==null){
        this.startTime = null;
    }else{
        this.startTime = (Date) startTime.clone();
    }
}
 
Example 11
Project: continuous-performance-evaluation   File: RouteSpecification.java   View Source Code Vote up 5 votes
/**
 * @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(Location origin, Location destination,
        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();
}
 
Example 12
Project: parabuild-ci   File: AbstractBuildScriptGenerator.java   View Source Code Vote up 5 votes
/**
 * Change list date.
 *
 * @param changeListDate
 */
public void setChangeListDate(final Date changeListDate) {
  if (changeListDate == null) {
    return;
  }
  this.changeListDate = (Date) changeListDate.clone();
}
 
Example 13
Project: coddy   File: JWTPrincipal.java   View Source Code Vote up 5 votes
public JWTPrincipal(
        final String login,
        final String firstName,
        final String lastName,
        final List<String> permissions,
        final Date beginActivationSession) {
    this.login = login;
    this.firstName = firstName;
    this.lastName = lastName;
    this.permissions = permissions;
    this.beginActivationSession = beginActivationSession != null ? (Date) beginActivationSession.clone() : null;
}
 
Example 14
Project: MonitorPlatform   File: RedisConfig.java   View Source Code Vote up 5 votes
/**
 * 
 * @param refreshTime 更新时间
 */
public void setRefreshTime(final Date refreshTime) {
    if(refreshTime==null){
        this.refreshTime = null;
    }else{
        this.refreshTime = (Date) refreshTime.clone();
    }
}
 
Example 15
Project: gitea-plugin   File: GiteaMilestone.java   View Source Code Vote up 4 votes
@JsonProperty("due_on")
public void setDueOn(Date dueOn) {
    this.dueOn = dueOn == null ? null : (Date) dueOn.clone();
}
 
Example 16
Project: gitea-plugin   File: GiteaCommitStatus.java   View Source Code Vote up 4 votes
@JsonProperty("created_at")
public void setCreatedAt(Date createdAt) {
    this.createdAt = createdAt == null ? null : (Date) createdAt.clone();
}
 
Example 17
Project: gitea-plugin   File: GiteaPullRequest.java   View Source Code Vote up 4 votes
@JsonProperty("created_at")
public void setCreatedAt(Date createdAt) {
    this.createdAt = createdAt == null ? null : (Date) createdAt.clone();
}
 
Example 18
Project: jdk8u-jdk   File: PKIXParameters.java   View Source Code Vote up 3 votes
/**
 * Sets the time for which the validity of the certification path
 * should be determined. If {@code null}, the current time is used.
 * <p>
 * Note that the {@code Date} supplied here is copied to protect
 * against subsequent modifications.
 *
 * @param date the {@code Date}, or {@code null} for the
 * current time
 * @see #getDate
 */
public void setDate(Date date) {
    if (date != null)
        this.date = (Date) date.clone();
    else
        date = null;
}
 
Example 19
Project: openjdk-jdk10   File: PKIXParameters.java   View Source Code Vote up 3 votes
/**
 * Sets the time for which the validity of the certification path
 * should be determined. If {@code null}, the current time is used.
 * <p>
 * Note that the {@code Date} supplied here is copied to protect
 * against subsequent modifications.
 *
 * @param date the {@code Date}, or {@code null} for the
 * current time
 * @see #getDate
 */
public void setDate(Date date) {
    if (date != null)
        this.date = (Date) date.clone();
    else
        date = null;
}
 
Example 20
Project: parabuild-ci   File: AbstractBuildScriptGenerator.java   View Source Code Vote up 2 votes
/**
 * Sets required date and time the build started at.
 *
 * @param startedAt date and time the build started at.
 */
public final void setBuildStartedAt(final Date startedAt) {
  this.buildStartedAt = (Date) startedAt.clone();
}