개발/java

java 형변환 String to Date , Date to String

Yunikism 2023. 6. 30. 11:44
728x90

 

문자열을 날짜로 변환

String str_day = "2023-06-30 11:45:00";

SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Date d_day = fmt.parse(str_day);

 


 

날짜를 문자열로 변환

Date d_day = new Date();

SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String str_day = fmt.format(d_day);

 

 

 

'개발 > java' 카테고리의 다른 글

@requestparam null 허용  (0) 2024.02.20
POI cell 색상 색상표  (0) 2024.01.26
java split 마침표(.) 역슬래시(\\)  (0) 2023.08.10
java 형변환 String to int, int to String  (0) 2023.06.30
java 일시정지 time sleep  (0) 2023.04.20