当前位置:网站首页>Get current system date
Get current system date
2022-06-28 11:02:00 【Hello_ xzy_ Word】
Get the current date of the system
Sometimes , We only need to get the current date information , In some old systems , The following statements may be used :
public class Main {
public static void main(String[] args) {
Date today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(0);
}
}
at present ,Date Class setHours 、 setMinutes 、setSeconds Method has been marked as deprecated , also , It is recommended that programmers use Calendar Class set Method operation time :

Here is by using Calendar Class set Method to obtain the code of the current system date :
public class Main {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Date today = calendar.getTime();
}
}
边栏推荐
- DlhSoft Kanban Library for WPF
- SQL中的DQL、DML、DDL和DCL是怎么区分和定义的
- [Agora] get an Agora_ Example usage of refptr object
- 知道 Redis RDB 这些细节,可以少踩很多坑
- Wireless communication module fixed-point transmission - point to multipoint specific transmission application
- flink1.15,支持mysql视图吗?我这边在table-name处配置视图名保存,找不到表。想
- metersphere使用js刷新当前页面
- NFT卡牌链游系统开发dapp搭建技术详情
- MySQL common commands for viewing database performance
- [practice] 1364- implement a perfect waterfall flow component on the mobile terminal (with source code)
猜你喜欢
![[Li Kou - dynamic planning] sort out topic 1: basic topics: 509, 70, 746, 62, 63, 343, 96 (with links, topic descriptions, problem solving methods and codes)](/img/02/4dbd97c8b8df1c96b7c8e1460aeda2.png)
[Li Kou - dynamic planning] sort out topic 1: basic topics: 509, 70, 746, 62, 63, 343, 96 (with links, topic descriptions, problem solving methods and codes)

Move command

MySQL(一)

Remote connection of raspberry pie in VNC viewer mode without display

JS基础1-JS引入与运算符

Dataease installation upgrade

爱可可AI前沿推介(6.28)

Summary of spatial temporal time series prediction modeling methods

Threads and thread pools

线程和线程池
随机推荐
选择哪种编程语言,会吸引优秀的人才?
Markdown -- basic usage syntax
NFT卡牌链游系统开发dapp搭建技术详情
Installing MySQL database (CentOS) in Linux source code
Oracle 日期格式化异常:无效数字
Understanding of FTP protocol
AQS understanding
Excel导入导出便捷工具类
将浏览器中的文件 url转换为File流
[Agora] get an Agora_ Example usage of refptr object
JS基础3
李宏毅《机器学习》丨7. Conclusion(总结)
关于Pytorch中双向LSTM的输出表示问题
[practice] 1364- implement a perfect waterfall flow component on the mobile terminal (with source code)
DlhSoft Kanban Library for WPF
Basic 02: variable, remember the mobile number of the object
Redis数据库
How to distinguish and define DQL, DML, DDL and DCL in SQL
【剑指Offer】49. 丑数
获取系统当前日期