아무거나

string to date / date to string 형변환 본문

Java & Kotlin/Java

string to date / date to string 형변환

전봉근 2019. 6. 20. 11:07
반응형

String to Date

String from = "2013-04-08 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);​
반응형
Comments