当前位置:网站首页>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
边栏推荐
- JZ70 矩形覆盖
- Qt reads Json files (including source code + comments)
- 20 Lectures on Disassembly of Multi-merchant Mall System Functions-Platform Distribution Overview
- 看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!
- Mobius inversion study notes
- QueryWrapper method explained
- JZ81 调整数组顺序使奇数位于偶数前面(二)-相对位置变化
- 数字孪生园区场景中的坐标知识
- 一文搞懂│php 中的 DI 依赖注入
- 【暑期集训第一周:搜索】【DFS&&BFS】
猜你喜欢
随机推荐
小心 transmittable-thread-local 的这个坑
uWSGI看这几篇就够了
NC22 合并两个有序的数组
2022 年值得尝试的 7 个 MQTT 客户端工具
时间戳格式化「建议收藏」
代码随想录笔记_哈希_61扑克牌中的顺子
CNN经典模型汇总[通俗易懂]
CWE4.8:2022年危害最大的25种软件安全问题
链表的归并排序[自顶向下分治 || 自低向上合并]
1.NVIDIA Deepstream开发指南中文版--欢迎使用 DeepStream 文档
sql2008数据库置疑的解决方法_sqlserver2008数据库可疑
坚持自主创新 线控底盘领军企业英创汇智获数亿元B+轮融资
面试官:可以谈谈乐观锁和悲观锁吗
dogs vs cats 二分类问题vgg16迁移学习
我的创作纪念日
Coordinate knowledge in digital twin campus scenarios
Detailed explanation of the principle of JWT_The principle of electromagnetic induction
智能座舱供应链的“新主角”
JZ10 斐波那契数列
tiup mirror modify







![[LeetCode]剑指 Offer 55 - I. 二叉树的深度](/img/97/d2ae4a28e553cfe9889d3be2d2360e.png)

