Skip to content

Commit 2398200

Browse files
authored
Update GeneratePresignedURL.java
Updating the code sample not to use java.util.Date since it is good coding practice not to use that.
1 parent afa788b commit 2398200

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

java/example_code/s3/src/main/java/aws/example/s3/GeneratePresignedURL.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import java.io.IOException;
3636
import java.net.URL;
37+
import java.time.Instant;
3738

3839
public class GeneratePresignedURL {
3940

@@ -49,8 +50,7 @@ public static void main(String[] args) throws IOException {
4950
.build();
5051

5152
// Set the presigned URL to expire after one hour.
52-
java.util.Date expiration = new java.util.Date();
53-
long expTimeMillis = expiration.getTime();
53+
long expTimeMillis = Instant.now().toEpochMilli();
5454
expTimeMillis += 1000 * 60 * 60;
5555
expiration.setTime(expTimeMillis);
5656

@@ -75,4 +75,4 @@ public static void main(String[] args) throws IOException {
7575
}
7676
}
7777

78-
// snippet-end:[s3.java.generate_presigned_url.complete]
78+
// snippet-end:[s3.java.generate_presigned_url.complete]

0 commit comments

Comments
 (0)