当前位置:网站首页>[Method for converting timestamp to normal time format]
[Method for converting timestamp to normal time format]
2022-08-08 21:02:00 【child running in the sun】
I encountered the problem of converting the timestamp to the normal time format in the project, record it here:
public class DateUtil {public static String timeStamp2Date(String time){Long timeLong = Long.parseLong(time);SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//The time format to be convertedDate date;try {date = sdf.parse(sdf.format(timeLong));return sdf.format(date);} catch (ParseException e) {e.printStackTrace();return null;}}}
Method call
String time = DateUtil.timeStamp2Date(result.getString("WEATHER_DATE"))
Thanks for reading.
边栏推荐
猜你喜欢
随机推荐
Simple Swing interface notes
PHP传递任意数量的函数参数
单片机--IIC总线篇
wp-ctfshow-web10 (group up注入)
OneNote 教程,如何在 OneNote 中检查拼写?
VSCode 必知必会的 20 个快捷键
go基于泛型实现继承
Kotlin解析String路径小知识
目标检测论文 Bridng the Gap Between Anchor-based and Anchor-free Detection via ATSS
[MEF]第04篇 MEF的多部件导入(ImportMany)和目录服务
单片机——串口通信(从串口接收多位数据保存到数组,发送多位数据到串口)
IO in Kotlin flow
360杜跃进ISC演讲:保障信创软件的可信性和安全性是信创安全体系的基础
一下科技:未来短视频行业发展呈四大趋势
昇腾Ascend 随记 —— TensorFlow 模型迁移
常见的病毒(攻击)分类
学习笔记:第二部分 队列
关于KotlinAndroid遇到的小知识
比较器? 如何使用比较器? 如何自定义比较器?
GeoServer入门学习:02-安装部署