728x90
반응형
기본적으로 LocalDateTime에는 timezone이 없기 때문에 따로 세팅을 해주어야한다.
먼저 now를 생성할 때 다음과 같이 UTC 시간을 준다.
LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
그 다음 timezone을 세팅할 때 다음과 같이 해준다.
now..atZone(TimeZone.getDefault().toZoneId())
.format(DateTimeFormatter.RFC_1123_DATE_TIME)
어떤 형식으로 보여줄 지는 다음 사이트를 참고하면 된다.
DateTimeFormatter (Java Platform SE 8 ) (oracle.com)
728x90
반응형
'Back-End > Spring Boot' 카테고리의 다른 글
Spring Boot | MQTT ( Mosquitto ) with Kafka | MQTT 사용하기 (2) | 2024.01.10 |
---|---|
Spring Boot | @AuthenticationPrincipal in Spring Security (0) | 2023.09.06 |
Spring boot | Teams Adaptivecard webhook 전송하기 (0) | 2023.08.24 |
Spring Boot | Java List, Map 초기값 주어진 채로 선언하기 (0) | 2023.08.24 |
Spring Boot | @SQLDelete (삭제 시 deleted 컬럼 변경) (0) | 2023.08.23 |