import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class LocalDateTimeExample {
public static void main(String[] args) {
// 현재 날짜와 시간 가져오기
LocalDateTime now = LocalDateTime.now();
// DateTimeFormatter를 사용하여 원하는 형식으로 포맷팅
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = now.format(formatter);
// 결과 출력
System.out.println("Formatted Date: " + formattedDate);
}
}
reference
https://stackoverflow.com/questions/1156468/how-to-format-a-java-sql-timestamp-for-displaying
'Programming > Java' 카테고리의 다른 글
[JPA] JPA 시작 - SQL 잘 작성하는 개발자 (0) | 2024.02.17 |
---|---|
[Java] 패키지 구조 (0) | 2023.12.20 |
[Servlet / JSP] JSP 출력 버퍼 (0) | 2023.08.22 |
[Servlet / JSP] 서블릿 (0) | 2023.08.17 |
[Servlet / JSP] 웹 애플리케이션 (0) | 2023.08.13 |