前端之家收集整理的这篇文章主要介绍了
oracle unix时间戳格式化,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
直接看到代码:
public static String toStringL(Long time,String pattern) {
if (time.longValue() > 0L) {
if (time.toString().length() == 10) {
time = Long.valueOf(time.longValue() * 1000L);
}
Date date = new Date(time.longValue());
String str = toString(date,pattern);
return str;
}
return "";
}
public static String toString(Date date,String pattern) {
if (date == null) {
date = new Date();
}
if (pattern == null) {
pattern = "yyyy-MM-dd";
}
String dateString = "";
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
try {
dateString = sdf.format(date);
} catch (Exception ex) {
ex.printStackTrace();
}
return dateString;
}
原文链接:https://www.f2er.com/oracle/212763.html