当前位置:网站首页>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 capitalizedS
to 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
边栏推荐
猜你喜欢
随机推荐
锁定和并发控制(一)
CWE4.8:2022年危害最大的25种软件安全问题
看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!
更舒适更安全更时尚 凯翼2023款炫界正式上市
牛客的课程订单分析[分组统计时如何取指定行字段?]
mysql 《一》触发器
开始使用 NVIDIA Jetson Orin 上的深度学习加速器
总结:不同语言比较总结
一文搞懂│php 中的 DI 依赖注入
word公式复制到另一个word当中出现图片解决方案
uniapp 小程序 动态style class
JZ32 从上往下打印二叉树
JZ40 最小的K个数
QueryWrapper方法解释
制胜精细化运营时代 华为应用市场打出内容、场景、商业运营组合拳
“绿色低碳+数字孪生“双轮驱动,解码油气管道站升级难点
julia系列1:介绍与安装
互联网刚需岗位 前景一片大好?
3.NVIDIA Deepstream开发指南中文版--Deepstream 环境配置
基于深度学习的机器人目标识别和跟踪