Java将Unix时间戳转换成指定格式日期时间:2021-01-27 02:37:11public String TimeStamp2Date(String timestampString, String formats){ Long timestamp = Long.parseLong(timestampString)*1000; String date = new java.text.SimpleDateFormat(formats).format(new java.util.Date(timestamp)); return date; } 当调用TimeStampToDate("1252639886", "yyyy-MM-dd HH:mm:ss"); 返回值:2009-11-09 11:31:26