import java.util.Date;
import java.text.SimpleDateFormat;
public class TimestampConverter {
public static void main(String[] args) {
long timestamp = 1612345678901L;
Date date = new Date(timestamp);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedDateTime = sdf.format(date);
System.out.println(formattedDateTime);
}
}
Java 时间戳转换为yyyy-MM-dd格式
发布时间 2023-10-30 15:31:59作者: (Play)