Skip to content

Commit

Permalink
base, core: remove all references to java.util.Date
Browse files Browse the repository at this point in the history
This also removes deprecated members.
  • Loading branch information
schildbach committed Sep 2, 2024
1 parent 3462725 commit c43ef27
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.time.Duration;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.Date;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down
7 changes: 0 additions & 7 deletions core/src/main/java/org/bitcoinj/core/AbstractBlockChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -1066,12 +1065,6 @@ public Instant estimateBlockTimeInstant(int height) {
}
}

/** @deprecated use {@link #estimateBlockTimeInstant(int)} */
@Deprecated
public Date estimateBlockTime(int height) {
return Date.from(estimateBlockTimeInstant(height));
}

/**
* Returns a future that completes when the block chain has reached the given height. Yields the
* {@link StoredBlock} of the block that reaches that height first. The future completes on a peer thread.
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/org/bitcoinj/core/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -739,15 +738,6 @@ public long getTimeSeconds() {
return time.getEpochSecond();
}

/**
* Returns the time at which the block was solved and broadcast, according to the clock of the solving node.
* @deprecated use {@link #time()}
*/
@Deprecated
public Date getTime() {
return Date.from(time());
}

// For testing only
void setTime(Instant time) {
unCacheHeader();
Expand Down
22 changes: 0 additions & 22 deletions core/src/main/java/org/bitcoinj/core/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
Expand Down Expand Up @@ -569,12 +568,6 @@ public Optional<Instant> updateTime() {
return Optional.ofNullable(updateTime);
}

/** @deprecated use {@link #updateTime()} */
@Deprecated
public Date getUpdateTime() {
return Date.from(updateTime().orElse(Instant.EPOCH));
}

/**
* Sets the update time of this transaction.
* @param updateTime update time
Expand All @@ -590,15 +583,6 @@ public void clearUpdateTime() {
this.updateTime = null;
}

/** @deprecated use {@link #setUpdateTime(Instant)} or {@link #clearUpdateTime()} */
@Deprecated
public void setUpdateTime(Date updateTime) {
if (updateTime != null && updateTime.getTime() > 0)
setUpdateTime(updateTime.toInstant());
else
clearUpdateTime();
}

/**
* These constants are a part of a scriptSig signature on the inputs. They define the details of how a
* transaction can be redeemed, specifically, they control how the hash of the transaction is calculated.
Expand Down Expand Up @@ -1737,12 +1721,6 @@ public Instant estimateUnlockTime(AbstractBlockChain chain) {
((TimeLock) locktime).timestamp();
}

/** @deprecated use {@link #estimateUnlockTime(AbstractBlockChain)} */
@Deprecated
public Date estimateLockTime(AbstractBlockChain chain) {
return Date.from(estimateUnlockTime(chain));
}

/**
* Returns the purpose for which this transaction was created. See the javadoc for {@link Purpose} for more
* information on the point of this field and what it can be.
Expand Down
14 changes: 0 additions & 14 deletions core/src/main/java/org/bitcoinj/core/TransactionConfidence.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import javax.annotation.Nullable;
import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Locale;
import java.util.Objects;
Expand Down Expand Up @@ -347,13 +346,6 @@ public Optional<Instant> getLastBroadcastTime() {
return Optional.ofNullable(lastBroadcastTime);
}

/** @deprecated use {@link #getLastBroadcastTime()} */
@Deprecated
@Nullable
public Date getLastBroadcastedAt() {
return lastBroadcastTime != null ? Date.from(lastBroadcastTime) : null;
}

/**
* Set the time the transaction was last announced to us.
* @param lastBroadcastTime time the transaction was last announced to us
Expand All @@ -362,12 +354,6 @@ public void setLastBroadcastTime(Instant lastBroadcastTime) {
this.lastBroadcastTime = Objects.requireNonNull(lastBroadcastTime);
}

/** @deprecated use {@link #setLastBroadcastTime(Instant)} */
@Deprecated
public void setLastBroadcastedAt(Date lastBroadcastedAt) {
setLastBroadcastTime(lastBroadcastedAt.toInstant());
}

@Override
public synchronized String toString() {
StringBuilder builder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import javax.annotation.Nullable;
import java.time.Instant;
import java.util.Date;
import java.util.Locale;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import java.security.KeyStoreException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -261,12 +260,6 @@ public Instant time() {
return Instant.ofEpochSecond(paymentDetails.getTime());
}

/** @deprecated use {@link #time()} */
@Deprecated
public Date getDate() {
return Date.from(time());
}

/**
* Returns the expires time of the payment request, or empty if none.
*/
Expand All @@ -277,15 +270,6 @@ public Optional<Instant> expires() {
return Optional.empty();
}

/** @deprecated use {@link #expires()} */
@Nullable
@Deprecated
public Date getExpires() {
return expires()
.map(Date::from)
.orElse(null);
}

/**
* This should always be called before attempting to call sendPayment.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.Level;
Expand Down
27 changes: 0 additions & 27 deletions core/src/main/java/org/bitcoinj/wallet/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -3885,13 +3884,6 @@ public long getLastBlockSeenTimeSecs() {
return lastBlockSeenTime().map(Instant::getEpochSecond).orElse((long) 0);
}

/** @deprecated use {@link #lastBlockSeenTime()} */
@Deprecated
@Nullable
public Date getLastBlockSeenTime() {
return lastBlockSeenTime().map(Date::from).orElse(null);
}

/**
* Returns the height of the last seen best-chain block. Can be 0 if a wallet is brand new or -1 if the wallet
* is old and doesn't have that data.
Expand Down Expand Up @@ -5684,15 +5676,6 @@ public void setKeyRotationTime(long timeSecs) {
setKeyRotationTime(Instant.ofEpochSecond(timeSecs));
}

/** @deprecated use {@link #setKeyRotationTime(Instant)} */
@Deprecated
public void setKeyRotationTime(@Nullable Date time) {
if (time == null)
setKeyRotationTime((Instant) null);
else
setKeyRotationTime(Instant.ofEpochMilli(time.getTime()));
}

/**
* Returns the key rotation time, or empty if unconfigured. See {@link #setKeyRotationTime(Instant)} for a description
* of the field.
Expand All @@ -5701,16 +5684,6 @@ public Optional<Instant> keyRotationTime() {
return Optional.ofNullable(vKeyRotationTime);
}

/** @deprecated use {@link #keyRotationTime()} */
@Deprecated
public @Nullable Date getKeyRotationTime() {
Instant keyRotationTime = vKeyRotationTime;
if (keyRotationTime != null)
return Date.from(keyRotationTime);
else
return null;
}

/** Returns whether the keys creation time is before the key rotation time, if one was set. */
public boolean isKeyRotating(ECKey key) {
Instant keyRotationTime = vKeyRotationTime;
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/bitcoinj/wallet/WalletFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.sql.Time;
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledThreadPoolExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import java.net.UnknownHostException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
Expand Down
1 change: 0 additions & 1 deletion core/src/test/java/org/bitcoinj/core/TransactionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down

0 comments on commit c43ef27

Please sign in to comment.