当前位置:网站首页>Convert LocalDateTime to Date type
Convert LocalDateTime to Date type
2022-08-01 23:22:00 【ythswzgxlp】
//LocalDateTime is a date processing class, which can be set to year, month, day, hour, minute and second, which is equivalent to LocalDate+LocalTime//Get the current time through LocalDateTime.now(), specific to the year, month, day, hour, minute and secondLocalDateTime localDateTime = LocalDateTime.now();//Zoneld is used to identify the conversion rule between Instant and LocalDateTime, and is also the time zone ID//Get the system default time zone through the systemDefault of ZoneIdZoneId zoneId = ZoneId.systemDefault();//LocalDateTime can only display the local date and time, no time zone//ZoneIdDateTime to identify a date and time with a time zone//ZonedDateTime is equivalent to LocalDateTime+ZoneId//Convert LocalDateTime to ZoneDateTime through atZone(new ZoneID) of LocalDateTimeZonedDateTime zonedDateTime =localDateTime.atZone(zoneId);//The Instant class is used to record the timestamp of the event in the application// that is, convert the time into a moment//ZonedDateTime.toInstant is used to convert ZonedDateTime to Instant typeInstant instant = zonedDateTime.toInstant();//Use the Date.from(new instant) method to change to Date type, which represents the same point on the time axis as the passed instant.Date date = Date.from(instant);System.out.println(date);
The corresponding ZoneId, ZonedDateTime, and Instant have many methods to get the time in different situations
边栏推荐
- C#大型互联网平台管理框架源码:基于ASP.NET MVC+EF6+Bootstrap开发,支持多数据库
- 6133. Maximum number of packets
- 测试岗月薪5-9k,如何实现涨薪到25k?
- 简单3D渲染器的制作
- y84.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十五)
- How to better understand and do a good job?
- TCP 可靠吗?为什么?
- 数据分析04
- [LeetCode304周赛] 两道关于基环树的题 6134. 找到离给定两个节点最近的节点,6135. 图中的最长环
- qt-faststart 安装使用
猜你喜欢
C#大型互联网平台管理框架源码:基于ASP.NET MVC+EF6+Bootstrap开发,支持多数据库
数据分析04
解决yolov5训练时出现:“AssertionError: train: No labels in VOCData/dataSet_path/train.cache. Can not train ”
CAKE:一个用于多视图知识图谱补全的可扩展性常识感知框架
The monthly salary of the test post is 5-9k, how to increase the salary to 25k?
中职网络安全竞赛B7比赛部署流程
UML diagram of soft skills
6134. Find the closest node to the given two nodes - force double hundred code
6134. 找到离给定两个节点最近的节点-力扣双百代码
D - Linear Probing- 并查集
随机推荐
Avoid , ,
, and tags数据库表设计规则
nodejs--process
研发团队数字化转型实践
Chapter 11 Working with Dates and Times
cmd指令
CF1703G Good Key, Bad Key
Calculate the angle of a line defined by two points
IDEA常用插件
6132. All the elements in the array is equal to zero - quick sort method
chrome复制一张图片的base64数据
路径压缩、、
Data Organization --- Chapter 5 Trees and Binary Trees --- The Concept of Binary Trees --- Application Questions
域名重定向工具 —— SwitchHosts 实用教程
怎样做才能让这条SQL变成一条危险的SQL?
ping no reply
sys_kill系统调用
Oracle database is set to read-only and read-write
访问控制台中的选定节点
如何使用pywinauto和pyautogui将动漫小姐姐链接请回家