1616package io .jsonwebtoken ;
1717
1818import java .security .Key ;
19- import java .util . Date ;
19+ import java .time . Instant ;
2020import java .util .Map ;
2121
2222/**
@@ -198,16 +198,16 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
198198 * <p>A JWT obtained after this timestamp should not be used.</p>
199199 *
200200 * <p>This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
201- * the Claims {@link Claims#setExpiration(java.util.Date ) expiration} field with the specified value. This allows
201+ * the Claims {@link Claims#setExpiration(java.time.Instant ) expiration} field with the specified value. This allows
202202 * you to write code like this:</p>
203203 *
204204 * <pre>
205- * String jwt = Jwts.builder().setExpiration(new Date (System.currentTimeMillis() + 3600000)).compact();
205+ * String jwt = Jwts.builder().setExpiration(Instant.ofEpochMilli (System.currentTimeMillis() + 3600000)).compact();
206206 * </pre>
207207 *
208208 * <p>instead of this:</p>
209209 * <pre>
210- * Claims claims = Jwts.claims().setExpiration(new Date (System.currentTimeMillis() + 3600000));
210+ * Claims claims = Jwts.claims().setExpiration(Instant.ofEpochMilli (System.currentTimeMillis() + 3600000));
211211 * String jwt = Jwts.builder().setClaims(claims).compact();
212212 * </pre>
213213 * <p>if desired.</p>
@@ -217,7 +217,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
217217 * @since 0.2
218218 */
219219 @ Override //only for better/targeted JavaDoc
220- JwtBuilder setExpiration (Date exp );
220+ JwtBuilder setExpiration (Instant exp );
221221
222222 /**
223223 * Sets the JWT Claims <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.5">
@@ -226,16 +226,16 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
226226 * <p>A JWT obtained before this timestamp should not be used.</p>
227227 *
228228 * <p>This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
229- * the Claims {@link Claims#setNotBefore(java.util.Date ) notBefore} field with the specified value. This allows
229+ * the Claims {@link Claims#setNotBefore(java.time.Instant ) notBefore} field with the specified value. This allows
230230 * you to write code like this:</p>
231231 *
232232 * <pre>
233- * String jwt = Jwts.builder().setNotBefore(new Date ()).compact();
233+ * String jwt = Jwts.builder().setNotBefore(Instant.now ()).compact();
234234 * </pre>
235235 *
236236 * <p>instead of this:</p>
237237 * <pre>
238- * Claims claims = Jwts.claims().setNotBefore(new Date ());
238+ * Claims claims = Jwts.claims().setNotBefore(Instant.now ());
239239 * String jwt = Jwts.builder().setClaims(claims).compact();
240240 * </pre>
241241 * <p>if desired.</p>
@@ -245,7 +245,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
245245 * @since 0.2
246246 */
247247 @ Override //only for better/targeted JavaDoc
248- JwtBuilder setNotBefore (Date nbf );
248+ JwtBuilder setNotBefore (Instant nbf );
249249
250250 /**
251251 * Sets the JWT Claims <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.6">
@@ -254,7 +254,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
254254 * <p>The value is the timestamp when the JWT was created.</p>
255255 *
256256 * <p>This is a convenience method. It will first ensure a Claims instance exists as the JWT body and then set
257- * the Claims {@link Claims#setIssuedAt(java.util.Date ) issuedAt} field with the specified value. This allows
257+ * the Claims {@link Claims#setIssuedAt(java.time.Instant ) issuedAt} field with the specified value. This allows
258258 * you to write code like this:</p>
259259 *
260260 * <pre>
@@ -263,7 +263,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
263263 *
264264 * <p>instead of this:</p>
265265 * <pre>
266- * Claims claims = Jwts.claims().setIssuedAt(new Date ());
266+ * Claims claims = Jwts.claims().setIssuedAt(Instant.now ());
267267 * String jwt = Jwts.builder().setClaims(claims).compact();
268268 * </pre>
269269 * <p>if desired.</p>
@@ -273,7 +273,7 @@ public interface JwtBuilder extends ClaimsMutator<JwtBuilder> {
273273 * @since 0.2
274274 */
275275 @ Override //only for better/targeted JavaDoc
276- JwtBuilder setIssuedAt (Date iat );
276+ JwtBuilder setIssuedAt (Instant iat );
277277
278278 /**
279279 * Sets the JWT Claims <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.7">
0 commit comments