当前位置:网站首页>Simpledateformat concrete classes for formatting and parsing dates
Simpledateformat concrete classes for formatting and parsing dates
2022-06-24 23:22:00 【Programmer Jiuan】
SimpleDateFormat Specific classes for formatting and parsing dates
SimpleDateFormat sdf = new SimpleDateFormat("yyyy year MM month dd Japan HH when mm branch ss second ");
Date to string
y Represents the year M Representative month d On behalf of the day E On behalf of the week H representative 24 Decimal hours h representative 12 Decimal hours
m For minutes s On behalf of the second ( uppercase )S On behalf of ms
// Format date as text
String format = sdf.format(date);
System.out.println(format);//2021 year 05 month 26 Japan 16 when 23 branch 01 second
// Parse the string to Date Time
Date parse = sdf.parse("2021 year 05 month 26 Japan 16 when 07 branch 25 second ");
System.out.println(parse);//Wed May 26 16:07:25 CST 2021
Date date1 = new Date();
// Judge whether the current time is between or after the set time
boolean after = date1.after(parse);
System.out.println(" Current time is after the set time :"+after);
boolean before = date1.before(parse);
System.out.println(" The current time is before the set time :"+before);
边栏推荐
- Tech Talk 活动回顾|云原生 DevOps 的 Kubernetes 技巧
- Super detailed cookie addition, deletion, modification and query
- QT to place the form in the lower right corner of the desktop
- Some updates about a hand slider (6-18, JS reverse)
- [JS] - [array application] - learning notes
- 03_SpingBoot 核心配置文件
- Detailed explanation of online group chat and dating platform project (servlet implementation)
- Gocolly manual
- Laravel scheduled task
- golang convert map to json string
猜你喜欢
宁德时代定增450亿:高瓴认购30亿 曾毓群仍控制23%股权
File contains vulnerability issues
Dig deep into MySQL - resolve the clustered index / secondary index / federated index of InnoDB storage engine
idea创建模块提示已存在
Tech talk activity review kubernetes skills of cloud native Devops
伪原创智能改写api百度-收录良好
EMI的主要原因-工模电流
[JS] - [tree] - learning notes
Case analysis: using "measurement" to improve enterprise R & D efficiency | ones talk
Main cause of EMI - mold current
随机推荐
Laravel authentication module auth
EMI的主要原因-工模电流
Dig deep into MySQL - resolve the clustered index / secondary index / federated index of InnoDB storage engine
[ROS play with turtle turtle]
How to add Google maps to a project
The large-scale market of graduate dormitory! Here comes the enviable graduate dormitory!
Docker-mysql8-master-slave
华为机器学习服务语音识别功能,让应用绘“声”绘色
378. Knight placement
[JS] - [tree] - learning notes
Online group chat and dating platform test point
SimpleDateFormat 格式化和解析日期的具体类
InnoDB, the storage engine of MySQL Architecture Principle_ Redo log and binlog
376. machine tasks
【UVM入门 ===> Episode_8 】~ Sequence 和 Sequencer、Sequence 层次化
Canvas to add watermark to pictures
03_ Spingboot core profile
RT thread uses RT kprintf
Paddledtx v1.0 has been released, and its security and flexibility have been comprehensively improved!
Blogs personal blog test point (manual test)