当前位置:网站首页>[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);
}
}
边栏推荐
- Simple code implementation of addition, subtraction, multiplication and division calculator
- Perfect ending | detailed explanation of the implementation principle of go Distributed Link Tracking
- Solve the problem that IEEE latex template cannot display Chinese
- [wechat applet] 6.1 applet configuration file
- jenkins相关
- Copy word content to excel and automatically divide it into multiple columns
- Why do Chinese programmers change jobs?
- [wechat applet] 3 The first wechat applet
- Leetcode 2176. 统计数组中相等且可以被整除的数对
- Player practice 18 xresample
猜你喜欢

Markdown edit

Dynamic search advertising intelligent search for matching keywords

sql跨库注入

How to package QT program learning records with inno setup

QT to realize the simple use of SQLite database

Design of PLC intelligent slave station based on PROFIBUS DP protocol

selenium-webdriver之断言

2022版Redis数据删除策略

通信流量分析

For cross-border e-commerce, the bidding strategy focusing more on revenue - Google SEM
随机推荐
数据的收集
Leetcode 2176. Count equal and divisible pairs in an array
Markdown edit
Reverse order of Excel
How test engineers transform test and open
Visual studio common shortcuts
How to package QT program learning records with inno setup
Program analysis and Optimization - 6 loop optimization
Can you believe it? It took me only two days to develop a management system
Introduction to QT reflection mechanism and signal slot mechanism
Getting started alicloud haas510 open board DTU (version 2.0) --510-as
Unit test (I) unit test with JUnit
华为设备配置BGP AS号替换
Postgresql14 installation and use tutorial
程序分析与优化 - 6 循环优化
In C language, the main function calls another function, which is understood by assembly code
Why do Chinese programmers change jobs?
ADB command (2) use monkey to test
JMeter (V) pressure test of Excel file upload interface
Ppt cannot be opened, always prompt how to fix it