当前位置:网站首页>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
边栏推荐
- IDEA入门看这一篇就够了
- 6134. 找到离给定两个节点最近的节点-力扣双百代码
- chrome复制一张图片的base64数据
- 6132. All the elements in the array is equal to zero - quick sort method
- IDEA common plugins
- bat 之 特殊字符&转义
- [C language advanced] file operation (2)
- PostgreSQL 基础--常用命令
- chrome copies the base64 data of an image
- When using DocumentFragments add a large number of elements
猜你喜欢

文件查询匹配神器 【glob.js】 实用教程

数据分析04
![[Camp Experience Post] 2022 Cybersecurity Summer Camp](/img/1e/716bafc679dc67d3d54bcc21a3b670.png)
[Camp Experience Post] 2022 Cybersecurity Summer Camp

从0到1:图文投票小程序设计与研发笔记

D - Linear Probing- 并查集

【参营经历贴】2022网安夏令营

Leetcode 129求根节点到叶节点数字之和、104二叉树的最大深度、8字符串转换整数(atoi)、82删除排序链表中的重复元素II、204二分查找、94二叉树的中序遍历、144二叉树的前序遍历

How do programmers solve online problems gracefully?

从0到100:招生报名小程序开发笔记

邻接表与邻接矩阵
随机推荐
Chapter 19 Tips and Traps: Common Goofs for Novices
IDEA入门看这一篇就够了
解决端口占用
Background project Express-Mysql-Vue3-TS-Pinia page layout-sidebar menu
nodejs--process
Secondary Vocational Network Security Competition B7 Competition Deployment Process
chrome copies the base64 data of an image
Additional Features for Scripting
Loading configuration of Nacos configuration center
E - Integer Sequence Fair
cmd指令
Getting started with IDEA is enough to read this article
6133. Maximum number of packets
Deep Learning Fundamentals - Numpy-based Recurrent Neural Network (RNN) implementation and backpropagation training
Avoid , ,
, and tagsproblem solved
美赞臣EDI 940仓库装运订单详解
drf生成序列化类代码
UML diagram of soft skills
B. Difference Array--Codeforces Round #808 (Div. 1)