当前位置:网站首页>Timestamp formatting "recommended collection"
Timestamp formatting "recommended collection"
2022-08-02 18:38:00 【Full stack programmer webmaster】
大家好,又见面了,我是你们的朋友全栈君.
一、须知:
1. Pure numeric timestamp minutes2种,一种是10位的,Only the year, month, day, hour, minute, and second are included,也就是说,只精确到秒.一种是13位的,包含毫秒.这2Both are called timestamps,Timestamps are not only accurate to milliseconds.
10The bit timestamp is from1970-01-01到当前的秒数,注意,Not milliseconds,So you need to parse by milliseconds,要 * 1000 13The bit timestamp is from1970-01-01到当前的毫秒数,在java中用Instant对象对应.
2. timestampThe format string is capitalizedSto represent milliseconds.SThe number of bits strictly corresponds to the number of milliseconds,否则报错.If the specification requires precision to the millisecond,Then give the time string,那肯定是3位.给2Bit accurate to less than a millisecond,给4位,The number of milliseconds obtained will also not contain information beyond the milliseconds.
@Test
def tt3(): Unit = {
val dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")
//Timestamps and time objects are interchangeable
println(LocalDateTime.parse("2020-04-04 08:08:08.123", dtf).toInstant(ZoneOffset.of("+8")).toEpochMilli) //1585958888123
println(LocalDateTime.ofInstant(Instant.ofEpochMilli(1585958888123L), ZoneOffset.of("+8"))) //2020-04-04T08:08:08.123
//这2个值是一样的,The parsing seconds above,下面的是 * 1000 Post-parse milliseconds
println(LocalDateTime.ofEpochSecond(1585958888L, 0, ZoneOffset.ofHours(8))) //2020-04-04T08:08:08
println(LocalDateTime.ofInstant(Instant.ofEpochMilli(1585958888000L), ZoneOffset.of("+8"))) //2020-04-04T08:08:08
}3. LocalDateTime.ofEpochSecond(1585958888L, 0, ZoneOffset.ofHours(8))Used to convert seconds to a time object.LocalDateTime.ofInstant(Instant.ofEpochMilli(1585958888000L), ZoneOffset.of(“+8”))Used to convert milliseconds to a time object.Epoch的意思是从1970-01-01开始.
二、HiveSupport for timestamps in
Hive并没有提供13Conversion function for bit timestamps,但是load的时候,It will automatically recognize the shape as”2020-04-04 08:08:08.123″This timestamp with milliseconds,It will import normally and display and use normally.
Hive中10Conversion of bit-only numeric timestamps: https://www.cnblogs.com/dcx-1993/p/11359139.html
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/125151.html原文链接:https://javaforall.cn
边栏推荐
猜你喜欢
随机推荐
julia系列5:文本、图像、其他语言函数互动
3.NVIDIA Deepstream开发指南中文版--Deepstream 环境配置
DevOps开发工具对比
尚硅谷尚品项目汇笔记(三)
JZ40 最小的K个数
julia系列3:函数、模块与宏
低光数据集
莫比乌斯反演学习笔记
融云「 IM 进阶实战高手课」系列直播上线
机械臂速成小指南(十七):直线规划
记一次内部分享——瞎扯淡
【2022河南萌新联赛第(四)场:郑州轻工业大学】【部分思路题解+代码解析】
带你了解MySQL数据库
JZ9 用两个栈实现队列
多商户商城系统功能拆解20讲-平台端分销概况
工信部电子五所张志强:中国数据库行业发展趋势分析
总结:不同语言比较总结
ActiveMQ漫谈(一)
【[USACO12MAR]Cows in a Skyscraper G】【状压DP && DFS】
网御数据库审计系统配置Radius启用双因素/双因子(2FA/MFA)身份认证





![【[SCOI2005] 互不侵犯】【状压DP(含概念讲解)】](/img/93/667e81afeb99b1cce4eb8068e6ce14.png)



