java 10位和13时间戳转日期格式
/** 将10 or 13 位时间戳转为时间字符串* convert the number 1407449951 1407499055617 to date/time format timestamp*/public static String timestamp2Date(String str_num,String format ) {SimpleDateFormat sdf
·
/*
* 将10 or 13 位时间戳转为时间字符串
* convert the number 1407449951 1407499055617 to date/time format timestamp
*/
public static String timestamp2Date(String str_num,String format ) {
SimpleDateFormat sdf = new SimpleDateFormat(format);
if (str_num.length() == 13) {
String date = sdf.format(new Date(Long.parseLong(str_num)));
LogUtil.debug("timestamp2Date"+ "将13位时间戳:" + str_num + "转化为字符串:", date);
return date;
} else {
String date = sdf.format(new Date(Integer.parseInt(str_num) * 1000L));
LogUtil.debug("timestamp2Date" + "将10位时间戳:" + str_num + "转化为字符串:", date);
return date;
}
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)