Any help or hint would be greatly appreciated it.. I am using Spring Boot 2:56 The date and time show properly for field "transactionDate" field when debugging the code in intellij: 2023-01-15 23.35:05.0
Code:
public List < TransactionEntity > findByFromAccountIdOrToAccountId(Long accountId) {
AccountEntity account = accountRepository.findByAccountId(accountId);
if (account == null) {
throw new AccountException("account cannot be found in account table accountId:" + accountId);
}
List < TransactionEntity > list = transactionRepository.findByFromAccountOrToAccount(account, account);
return list;
}
TransactionEntity.java
private Timestamp transactionDate;
For the transactionDate
field I used import java.sql.Timestamp; In postman it is showing: "transactionDate": 1673843714000,
How can I show the proper date and time in postman result such as "2023-01-15 23:35:05.0".
"transactionDate": 1673843714000
This is how Timestamp looks like. If you want to show like you mention use LocalDateTime instead.
private LocalDateTime transactionDate;
Or convert
transactionDate.toLocalDateTime().toLocalDate()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.