Tag Archives: java timestamp to date

[Source | Java] Timestamp to Date & Date to String

Java에서 Timestamp를 String으로 변환하는 코드를 정리한다.


작성일 : 2021-06-18


// Define
long timestamp = 1623972777000L;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

1> Timestamp to Date

Date date = new Date(timestamp);
System.out.println(date);

2> Date to String

String dateStr = dateFormat.format(date);
System.out.println(dateStr);

3> String to Timestamp

[Link – String to Date & Date to Timestamp]