当前位置:网站首页>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);
边栏推荐
- Record the range of data that MySQL update will lock
- Spark 离线开发框架设计与实现
- 数字IC设计经验整理(二)
- 03_ Spingboot core profile
- Super detailed cookie addition, deletion, modification and query
- Financial management [5]
- 監聽 Markdown 文件並熱更新 Next.js 頁面
- Recommended movies: Northeast tiger, licorice pizza
- Financial management [3]
- Selection (026) - what is the output of the following code?
猜你喜欢

【js】-【數組、棧、隊列、鏈錶基礎】-筆記

Spark 离线开发框架设计与实现

Some updates about a hand slider (6-18, JS reverse)

Getting started with the go Cobra command line tool

Dig deep into MySQL - resolve the non clustered index of MyISAM storage engine

What kind of processor architecture is ARM architecture?
![[postgraduate entrance examination English] prepare for 2023, learn list8 words](/img/25/d1f2c2b4c0958d381db87e5ef96df9.jpg)
[postgraduate entrance examination English] prepare for 2023, learn list8 words

laravel 宝塔安全配置

【js】-【栈、队-应用】-学习笔记

慕思股份深交所上市:靠床垫和“洋老头”走红 市值224亿
随机推荐
The large-scale market of graduate dormitory! Here comes the enviable graduate dormitory!
How to submit the shopee opening and settlement flow?
Paddledtx v1.0 has been released, and its security and flexibility have been comprehensively improved!
EPICS record Reference 3 - - field available for all Records
Tech talk activity review kubernetes skills of cloud native Devops
【js】-【数组、栈、队列、链表基础】-笔记
Use of laravel verifier
EPICS记录参考3 -- 所有记录都有的字段
02_SpingBoot 入门案例
Gocolly manual
China solar window market trend report, technical dynamic innovation and market forecast
Research Report on market supply and demand and strategy of ceiling power supply device industry in China
EMI的主要原因-工模电流
Attention, postgraduate candidates! They are the easiest scams to get caught during the preparation period?!
InnoDB, the storage engine of MySQL Architecture Principle_ Redo log and binlog
Financial management [6]
Laravel message queue
2022 simulated 100 questions and simulated examination of high-altitude installation, maintenance and demolition
Research Report on research and investment prospects of China's container coating industry (2022 Edition)
Sword finger offer 13 Range of motion of robot