Skip to content

Commit f62491a

Browse files
committed
change the way of making timestamps
1 parent d321566 commit f62491a

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

app/src/main/java/hexlet/code/model/Url.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ public final class Url {
1818

1919
public Url(String name) {
2020
this.name = name;
21-
this.createdAt = LocalDateTime.now();
2221
}
2322
}

app/src/main/java/hexlet/code/model/UrlCheck.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,5 @@ public UrlCheck(Integer statusCode, String title, String h1, String description,
2828
this.title = title;
2929
this.h1 = h1;
3030
this.description = description;
31-
this.createdAt = LocalDateTime.now();
3231
}
3332
}

app/src/main/java/hexlet/code/repository/UrlCheckRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.sql.SQLException;
66
import java.sql.Statement;
77
import java.sql.Timestamp;
8+
import java.time.LocalDateTime;
89
import java.util.ArrayList;
910
import java.util.HashMap;
1011
import java.util.List;
@@ -27,7 +28,7 @@ public static void save(UrlCheck check) throws SQLException {
2728
stmt.setString(3, check.getH1());
2829
stmt.setString(4, check.getDescription());
2930
stmt.setLong(5, check.getUrlId());
30-
stmt.setTimestamp(6, Timestamp.valueOf(check.getCreatedAt()));
31+
stmt.setTimestamp(6, Timestamp.valueOf(LocalDateTime.now()));
3132
stmt.executeUpdate();
3233

3334
var keys = stmt.getGeneratedKeys();

app/src/main/java/hexlet/code/repository/UrlRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.sql.SQLException;
66
import java.sql.Statement;
77
import java.sql.Timestamp;
8+
import java.time.LocalDateTime;
89
import java.util.ArrayList;
910
import java.util.List;
1011
import java.util.Optional;
@@ -17,7 +18,7 @@ public static void save(Url url) throws SQLException {
1718
var stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)
1819
) {
1920
stmt.setString(1, url.getName());
20-
stmt.setTimestamp(2, Timestamp.valueOf(url.getCreatedAt()));
21+
stmt.setTimestamp(2, Timestamp.valueOf(LocalDateTime.now()));
2122
stmt.executeUpdate();
2223

2324
var keys = stmt.getGeneratedKeys();

0 commit comments

Comments
 (0)