当前位置:网站首页>SimpleDateFormat 格式化和解析日期的具体类
SimpleDateFormat 格式化和解析日期的具体类
2022-06-24 19:42:00 【程序员久安】
SimpleDateFormat 格式化和解析日期的具体类

SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
日期转字符串
y 代表年 M 代表月 d 代表日 E 代表星期 H 代表24进制的小时 h 代表12进制的小时
m 代表分钟 s 代表秒 (大写的)S 代表毫秒
//把日期格式化文本
String format = sdf.format(date);
System.out.println(format);//2021年05月26日 16时23分01秒
//把字符串解析为Date时间
Date parse = sdf.parse("2021年05月26日 16时07分25秒");
System.out.println(parse);//Wed May 26 16:07:25 CST 2021

Date date1 = new Date();
//判断当前时间是否在设定时间之间或者之后
boolean after = date1.after(parse);
System.out.println("当前时间在设定时间之后:"+after);
boolean before = date1.before(parse);
System.out.println("当前时间在设定时间之前:"+before);
边栏推荐
- Laravel pagoda security configuration
- 文件包含漏洞问题
- Non single file component
- [text data mining] Chinese named entity recognition: HMM model +bilstm_ CRF model (pytoch) [research and experimental analysis]
- Research Report on market supply and demand and strategy of China's solar charging controller industry
- . Net 7 Preview 1 has been officially released
- Servlet
- Selection (026) - what is the output of the following code?
- Blogs personal blog test point (manual test)
- Second IPO of Huafang group: grown up in Zanthoxylum bungeanum, trapped in Zanthoxylum bungeanum
猜你喜欢

Simulated 100 questions and online simulated examination of high voltage electrician examination in 2022

03_SpingBoot 核心配置文件

01_SpingBoot 框架入门

07_ Springboot for restful style

Pousser l'information au format markdown vers le robot nail

How to submit the shopee opening and settlement flow?

The large-scale market of graduate dormitory! Here comes the enviable graduate dormitory!

Push markdown format information to the nailing robot

RT-thread使用rt-kprintf

Dynamic menu, auto align
随机推荐
对抗训练理论分析:自适应步长快速对抗训练
EPICS记录参考2--EPICS过程数据库概念
Dynamic menu, auto align
2022 safety officer-a certificate examination questions and answers
Selection (027) - what is the output of the following code?
[laravel series 7.9] test
EPICS record Reference 3 - - field available for all Records
go Cobra命令行工具入门
[untitled]
Laravel pagoda security configuration
加分利器 不负所托 | 知道创宇获攻防演练防守方感谢信!
Design and implementation of spark offline development framework
It's hard to hear C language? Why don't you take a look at my article (7) input and output
golang map clear
websocket学习
Notes for laravel model
Dig deep into MySQL - resolve the difference between clustered and non clustered indexes
Building Survey [2]
Solve the problem of port occupation
vulnhub DC: 2