当前位置:网站首页>[datetmeformatter] realize the conversion between localdatetime and text
[datetmeformatter] realize the conversion between localdatetime and text
2022-06-12 14:36:00 【Understand the principle + good code skills】
package org.example.testTime;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class TestDateTimeFormatter {
public static void main(String[] args) {
LocalDateTime now = LocalDateTime.now();
// step1.LocalDateTime Convert to this format
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String str = dtf.format(now);
System.out.println(str); // 2022-02-18 01:09:19
// step2. Text to LocalDateTime
LocalDateTime time = LocalDateTime.parse(str, dtf); // 2022-02-18T01:09:19
System.out.println(time);
}
}
边栏推荐
- Vs2012: cannot assign a value of type 'char *' to an entity of type 'lpwstr'
- Introduction to QT reflection mechanism and signal slot mechanism
- If you want to build brand awareness, what bidding strategy can you choose?
- C secret arts script Chapter 5 (paragraph) (Section 3)
- Notepad common settings
- Player practice 19 xaudio turn on audio
- Printing colored messages on the console with printf
- Two methods of implementing asynchronous calling function with QT
- Markdown edit
- Appnium (II) installation and basic use of mitmproxy
猜你喜欢
[ROC] aspriseocr C # English, Digital identification (not Chinese)
The original Xiaoyuan personal blog project that has been around for a month is open source (the blog has basic functions, including background management)
selenium之元素定位
Postgresql14 installation and use tutorial
Mémoire de l'examen d'entrée à l'université
Dynamic search advertising intelligent search for matching keywords
Tu oses le croire? Il m'a fallu deux jours pour développer un système de gestion.
Player practice 15 xdemux and avcodecparameters
Pay attention to click and pursue more users to enter the website. What bidding strategy can you choose?
webdriver入门
随机推荐
Mémoire de l'examen d'entrée à l'université
Sizeof calculation space size summary
Program analysis and Optimization - 6 loop optimization
C secret arts script Chapter 2 (detailed explanation of pointer) (Section 1)
NetCore结合CAP事件总线实现分布式事务——入门(1)
Use Baidu AIP to obtain the text in the specified area of the screen
C magic skill Chapter 4 (detailed explanation of memory function)
Player practice 11 audio resampling
Soft test (VI) Chrome browser installation selenium IDE
For cross-border e-commerce, the bidding strategy focusing more on revenue - Google SEM
用游戏来讲序列化与反序列化机制
[wechat applet] 5 Applet structure directory
Software package for optimization scientific research field
[OCR] aspriseocr C # English, number recognition (not Chinese)
Array one
selenium进阶
PMP agile knowledge points
完美收官|详解 Go 分布式链路追踪实现原理
[wechat applet] 4 Introduction to wechat developer tools
selenium之元素定位