Skip to content

Commit 469165b

Browse files
committed
fixed #401 Migrate spring-boot from 2 to 3
1 parent 0a303cb commit 469165b

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

src/main/java/org/woehlke/java/simpleworklist/domain/db/user/UserAccount.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import java.io.Serial;
1616
import java.io.Serializable;
17+
import java.time.LocalDateTime;
18+
import java.time.ZoneId;
1719
import java.util.Date;
1820
import java.util.UUID;
1921

@@ -83,7 +85,7 @@ public class UserAccount extends AuditModel implements Serializable, ComparableB
8385
//@NotNull
8486
@Temporal(value = TemporalType.TIMESTAMP)
8587
@Column(name="last_login_timestamp", nullable = false)
86-
private Date lastLoginTimestamp;
88+
private LocalDateTime lastLoginTimestamp;
8789

8890
//@NotNull
8991
@Column(name="account_non_expired", nullable = false)
@@ -125,7 +127,8 @@ public static UserAccount createUserAccount(
125127
final String userPassword,
126128
Context[] contexts
127129
){
128-
Date now = new Date();
130+
ZoneId zone = ZoneId.systemDefault();
131+
LocalDateTime now = LocalDateTime.now(zone);
129132
UserAccount u = new UserAccount();
130133
u.setUserEmail(userEmail);
131134
u.setUserFullname(userFullname);

src/main/java/org/woehlke/java/simpleworklist/domain/security/login/LoginSuccessServiceImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.woehlke.java.simpleworklist.domain.db.user.UserAccount;
1313
import org.woehlke.java.simpleworklist.domain.db.user.account.UserAccountRepository;
1414

15+
import java.time.LocalDateTime;
16+
import java.time.ZoneId;
1517
import java.util.Date;
1618

1719
@Slf4j
@@ -52,7 +54,9 @@ public UserAccount retrieveCurrentUser() throws UsernameNotFoundException {
5254
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
5355
public void updateLastLoginTimestamp(UserAccount user) {
5456
log.info("updateLastLoginTimestamp");
55-
user.setLastLoginTimestamp(new Date());
57+
ZoneId zone = ZoneId.systemDefault();
58+
LocalDateTime now = LocalDateTime.now(zone);
59+
user.setLastLoginTimestamp(now);
5660
userAccountRepository.saveAndFlush(user);
5761
}
5862

src/main/resources/templates/user/selfservice/profile.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ <h5>
5858
<span th:text="${user.userFullname}">user.userFullname</span>
5959
</td>
6060
<td>
61-
<span th:text="${user.lastLoginTimestamp}"></span>
61+
<span th:text="${user.lastLoginTimestamp}" th:if="${#locale.language eq 'en'}"></span>
62+
<span th:text="${user.lastLoginTimestamp}" th:if="${#locale.language eq 'de'}"></span>
6263
</td>
6364
<td>
64-
<span th:text="${user.rowCreatedAt}"></span>
65+
<span th:text="${user.rowCreatedAt}" th:if="${#locale.language eq 'en'}"></span>
66+
<span th:text="${user.rowCreatedAt}" th:if="${#locale.language eq 'de'}"></span>
6567
</td>
6668
</tr>
6769
</tbody>

src/test/java/org/woehlke/java/simpleworklist/config/UserAccountTestDataServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.woehlke.java.simpleworklist.domain.db.user.UserAccount;
1212
import org.woehlke.java.simpleworklist.domain.db.user.account.UserAccountService;
1313

14+
import java.time.LocalDateTime;
15+
import java.time.ZoneId;
1416
import java.util.Date;
1517
import java.util.UUID;
1618

@@ -44,7 +46,8 @@ public UserAccountTestDataServiceImpl(
4446
this.userAccountService = userAccountService;
4547
this.contextService = contextService;
4648
this.simpleworklistProperties = simpleworklistProperties;
47-
Date lastLoginTimestamp = new Date();
49+
ZoneId zone = ZoneId.systemDefault();
50+
LocalDateTime lastLoginTimestamp = LocalDateTime.now(zone);
4851
testUser = new UserAccount[emails.length];
4952
newContext = new NewContextForm[emails.length];
5053
for (int i = 0; i < testUser.length; i++) {

0 commit comments

Comments
 (0)