当前位置:网站首页>【时间戳转普通时间格式的方法】
【时间戳转普通时间格式的方法】
2022-08-08 20:56:00 【阳光下奔跑的小孩儿】
项目中遇到了时间戳转普通时间格式的问题,在此记录一下:
public class DateUtil {
public static String timeStamp2Date(String time) {
Long timeLong = Long.parseLong(time);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
Date date;
try {
date = sdf.parse(sdf.format(timeLong));
return sdf.format(date);
} catch (ParseException e) {
e.printStackTrace();
return null;
}
}
}
方法调用
String time = DateUtil.timeStamp2Date(result.getString("WEATHER_DATE"))
感谢读者的阅读.
边栏推荐
猜你喜欢

编译原理——LL1分析程序实验(C#)
GeoServer入门学习:06-发布多层级TIF地图大图数据
Flask 教程 第三章:Web表单

jmeter逻辑控制器使用

Redis布隆过滤器

语义分割FCN FPN UNet DeepLab HRNet SETR TransFuse...

澳洲ABM创新模式将销售代理权给到个体,让利消费者

Redis Bloom Filter

单片机--IIC总线篇

The new database is online | CnOpenData information transmission, software and information technology service industry basic information data of industrial and commercial registered enterprises
随机推荐
二叉树前序遍历、中序遍历、后序遍历的迭代版
Matlab用回归、SEIRD模型、聚类预测美国总统大选、新冠疫情对中美经济的影响
Flask 教程 第三章:Web表单
Redis布隆过滤器
怎样在网上开户买股票比较安全?如何办理开户业务?
学习笔记:第三章 栈与队列
Simple Swing interface notes
使用fontforge修改字体,只保留数字
GeoServer入门学习:02-安装部署
跨域问题 什么时候出现跨域问题 如何解决跨域问题
各类测试场景的检查点
高数_复习_第3章:一元函数积分学
Kotlin反射
go基于泛型实现继承
fastapi-后台任务、定时任务与消息队列
学习笔记:XML
昇腾Ascend 随记 —— 昇腾 AI 的基本架构
rust-异常机制
Kotlin reflection
The new database is online | CnOpenData information transmission, software and information technology service industry basic information data of industrial and commercial registered enterprises