String to Date

 

String from = "2023-01-10 11:11:00";

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);

 

복사했습니다!