IT/JAVA

[JAVA] String To Date , Date To String

아라니나노 2018. 11. 29. 13:59
반응형

정말 자주 쓰는 기능이지만 매번 찾고 매번 헷갈리는것 같다



String to Date

String from = "2018-11-28 10:10:10";

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

Date to = transFormat.parse(from);


Date to String 


Date from = new Date();

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

String to = transFormat.format(from);


반응형