본문 바로가기
1.개발/6.JAVA

[JAVA] Date → String, String → Date

by 벅스쭌 2020. 6. 19.

Date → String

SimpleDateFormat dateType = new SimpleDateFormat("yyyyMMddHHmmss");
String testDateString = dateType.format(new Date());

String → Date

SimpleDateFormat dateType = new SimpleDateFormat("yyyyMMddHHmmss");
String testDateString = dateType.format(new Date());//Result : 20200619144500
Date testDate = dateType.parse(dateString);

 

반응형

댓글0