Java Code Examples for java.util.Date#clone()
The following examples show how to use
java.util.Date#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: StockPriceHistoryExternalizable.java From training with MIT License | 6 votes |
public StockPriceHistoryExternalizable(String s, Date startDate, Date endDate, EntityManager em) { Date curDate = new Date(startDate.getTime()); symbol = s; while (!curDate.after(endDate)) { StockPriceEagerLazyImpl sp = em.find(StockPriceEagerLazyImpl.class, new StockPricePK(s, (Date) curDate.clone())); if (sp != null) { Date d = (Date) curDate.clone(); if (firstDate == null) { firstDate = d; } prices.put(d, sp); lastDate = d; } curDate.setTime(curDate.getTime() + msPerDay); } }
Example 2
Source File: HandlingEvent.java From pragmatic-microservices-lab with MIT License | 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(Cargo cargo, Date completionTime, Date registrationTime, Type type, 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 3
Source File: HandlingEvent.java From CargoTracker-J12015 with MIT License | 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; }
Example 4
Source File: StockPriceHistoryCompressUnbuffered.java From training with MIT License | 6 votes |
public StockPriceHistoryCompressUnbuffered(String s, Date startDate, Date endDate, EntityManager em) { Date curDate = new Date(startDate.getTime()); symbol = s; while (!curDate.after(endDate)) { StockPriceEagerLazyImpl sp = em.find(StockPriceEagerLazyImpl.class, new StockPricePK(s, (Date) curDate.clone())); if (sp != null) { Date d = (Date) curDate.clone(); if (firstDate == null) { firstDate = d; } prices.put(d, sp); lastDate = d; } curDate.setTime(curDate.getTime() + msPerDay); } }
Example 5
Source File: MarriageDataBase.java From MarriageMaster with GNU General Public License v3.0 | 6 votes |
public MarriageDataBase(final @NotNull MARRIAGE_PLAYER player1, final @NotNull MARRIAGE_PLAYER player2, final @Nullable MARRIAGE_PLAYER priest, final @NotNull Date weddingDate, final @Nullable String surname, final boolean pvpEnabled, final @Nullable MessageColor color, final @Nullable HOME home, final @Nullable Object databaseKey) { this.player1 = player1; this.player2 = player2; this.priest = priest; this.surname = surname; this.pvpEnabled = pvpEnabled; this.weddingDate = (Date) weddingDate.clone(); this.databaseKey = databaseKey; this.home = home; this.color = color; this.chatPrefix = ""; // TODO implement in db if(player1 instanceof MarriagePlayerDataBase && player2 instanceof MarriagePlayerDataBase) { ((MarriagePlayerDataBase) player1).addMarriage(this); ((MarriagePlayerDataBase) player2).addMarriage(this); } hash = player1.hashCode() * 53 + player2.hashCode(); }
Example 6
Source File: DateTimeHelper.java From uavstack with Apache License 2.0 | 6 votes |
/** * @param date * @return 复制新Date,不改变参数 */ public static Date nextDay(Date date) { Date newDate = (Date) date.clone(); long time = (newDate.getTime() / 1000) + 60 * 60 * 24; newDate.setTime(time * 1000); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { newDate = format.parse(format.format(newDate)); } catch (Exception ex) { System.out.println(ex.getMessage()); } return newDate; }
Example 7
Source File: HandlingEvent.java From pragmatic-microservices-lab with MIT License | 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(Cargo cargo, Date completionTime, Date registrationTime, Type type, 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 8
Source File: HandlingEvent.java From pragmatic-microservices-lab with MIT License | 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(Cargo cargo, Date completionTime, Date registrationTime, Type type, 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
Source File: HandlingEvent.java From pragmatic-microservices-lab with MIT License | 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; }
Example 10
Source File: TaskExecution.java From spring-cloud-task with Apache License 2.0 | 6 votes |
public TaskExecution(long executionId, Integer exitCode, String taskName, Date startTime, Date endTime, String exitMessage, List<String> arguments, String errorMessage, String externalExecutionId, Long parentExecutionId) { Assert.notNull(arguments, "arguments must not be null"); this.executionId = executionId; this.exitCode = exitCode; this.taskName = taskName; this.exitMessage = exitMessage; this.arguments = new ArrayList<>(arguments); this.startTime = (startTime != null) ? (Date) startTime.clone() : null; this.endTime = (endTime != null) ? (Date) endTime.clone() : null; this.errorMessage = errorMessage; this.externalExecutionId = externalExecutionId; this.parentExecutionId = parentExecutionId; }
Example 11
Source File: TimeAttribute.java From balana with Apache License 2.0 | 5 votes |
/** * Initialization code shared by constructors. * * @param date a <code>Date</code> object representing the specified time down to second * resolution. This date should have a date of 01/01/1970. If it does not, such a * date will be forced. If this object has non-zero milliseconds, they are combined * with the nanoseconds parameter. * @param nanoseconds the number of nanoseconds beyond the Date specified in the date parameter * @param timeZone the time zone specified for this object (or TZ_UNSPECIFIED if unspecified). * The offset to GMT, in minutes. * @param defaultedTimeZone the time zone actually used for this object (if it was originally * unspecified, the default time zone used). The offset to GMT, in minutes. */ private void init(Date date, int nanoseconds, int timeZone, int defaultedTimeZone) { // Shouldn't happen, but just in case... if (earlyException != null) throw earlyException; // get a temporary copy of the date Date tmpDate = (Date) (date.clone()); // Combine the nanoseconds so they are between 0 and 999,999,999 this.nanoseconds = DateTimeAttribute.combineNanos(tmpDate, nanoseconds); // now that the date has been (potentially) updated, store the time this.timeGMT = tmpDate.getTime(); // keep track of the timezone values this.timeZone = timeZone; this.defaultedTimeZone = defaultedTimeZone; // Check that the date is normalized to 1/1/70 if ((timeGMT >= DateAttribute.MILLIS_PER_DAY) || (timeGMT < 0)) { timeGMT = timeGMT % DateAttribute.MILLIS_PER_DAY; // if we had a negative value then we need to shift by a day if (timeGMT < 0) timeGMT += DateAttribute.MILLIS_PER_DAY; } }
Example 12
Source File: RouteSpecification.java From dddsample-core with MIT License | 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(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(); }
Example 13
Source File: RouteSpecification.java From pragmatic-microservices-lab with MIT License | 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 14
Source File: WantContext.java From mySSM with MIT License | 4 votes |
public void setModified(Date modified) { this.modified = modified == null ? null : (Date) modified.clone(); }
Example 15
Source File: UserRelease.java From mySSM with MIT License | 4 votes |
public void setModified(Date modified) { this.modified = modified == null ? null : (Date) modified.clone(); }
Example 16
Source File: GiteaMilestone.java From gitea-plugin with MIT License | 4 votes |
@JsonProperty("closed_at") public void setClosedAt(Date closedAt) { this.closedAt = closedAt == null ? null : (Date) closedAt.clone(); }
Example 17
Source File: UserPassword.java From mySSM with MIT License | 4 votes |
public void setModified(Date modified) { this.modified = modified == null ? null : (Date) modified.clone(); }
Example 18
Source File: PartRevisionDTO.java From eplmp with Eclipse Public License 1.0 | 4 votes |
public void setCreationDate(Date creationDate) { this.creationDate = (creationDate != null) ? (Date) creationDate.clone() : null; }
Example 19
Source File: Device.java From sentry-android with MIT License | 4 votes |
@SuppressWarnings("JdkObsolete") public Date getBootTime() { final Date bootTimeRef = bootTime; return bootTimeRef != null ? (Date) bootTimeRef.clone() : null; }
Example 20
Source File: FileMatch.java From openjdk-8-source with GNU General Public License v2.0 | 2 votes |
/** * Setter for property {@code lastModifiedBefore}. * @param lastModifiedBefore A file will be selected only if it was * last modified before {@code lastModifiedBefore}. * <br>This condition is ignored if {@code lastModifiedBefore} is * {@code null}. */ public void setLastModifiedBefore(Date lastModifiedBefore) { this.lastModifiedBefore = (lastModifiedBefore==null)?null:(Date)lastModifiedBefore.clone(); }