当前位置:网站首页>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
边栏推荐
猜你喜欢
![[LeetCode]剑指 Offer 55 - I. 二叉树的深度](/img/97/d2ae4a28e553cfe9889d3be2d2360e.png)
[LeetCode]剑指 Offer 55 - I. 二叉树的深度

julia系列5:文本、图像、其他语言函数互动

20 Lectures on Disassembly of Multi-merchant Mall System Functions-Platform Distribution Overview

打破千篇一律,DIY属于自己独一无二的商城

【服务器数据恢复】Raid阵列更换故障硬盘后数据同步失败的数据恢复案例

CefSharp practical demonstration

CefSharp实战演示

每日练习------定义一个N*N二维数组,从键盘上输入值,找出每行中最大值组成一个一维数组并输出;

从Oracle日志解析学习数据库内核原理

提高测试覆盖率的四大步骤
随机推荐
Qt读取Json文件(含源码+注释)
【[USACO12MAR]Cows in a Skyscraper G】【状压DP && DFS】
如何为项目匹配资源技能和要求?
Switch 块、Switch 表达式、Switch 模式匹配,越来越好用的 Switch
【[SCOI2005] 互不侵犯】【状压DP(含概念讲解)】
锁定和并发控制(二)
AI智能剪辑,仅需2秒一键提取精彩片段
《独行月球》
11.2-HJ86 求最大连续bit数
制胜精细化运营时代 华为应用市场打出内容、场景、商业运营组合拳
sql2008数据库置疑的解决方法_sqlserver2008数据库可疑
打破千篇一律,DIY属于自己独一无二的商城
Arduino 硬件编程语言基础学习入门
编写一个油猴脚本
链表的归并排序[自顶向下分治 || 自低向上合并]
【面经】被虐了之后,我翻烂了equals源码,总结如下
8大软件供应链攻击事件概述
记一次内部分享——瞎扯淡
CefSharp practical demonstration
软件测试面试中90%会遇到的问题:“你会搭建测试环境吗?”