当前位置:网站首页>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();
}
}
边栏推荐
- DataEase安装升级
- Katalon框架测试一个web页面操作实例代码
- Makefile简介
- Dataease installation upgrade
- MySQL(三)
- Wireshark数据抓包分析之FTP协议
- Mysql database overview and installation process
- JS基础1-JS引入与运算符
- Information hidden in the trend chart of Hong Kong London gold market
- MySQL installation configuration and solving the problem of forgetting root password when reinstalling MySQL
猜你喜欢

【monkey】monkey测试入门

How to use K-line diagram for technical analysis

动态库(共享库)的制作和使用

Remote connection of raspberry pie in VNC viewer mode without display

How does ETF position affect spot gold price?

Realization of a springboard machine

Dataease installation upgrade

Summary of characteristics of five wireless transmission protocols of Internet of things
![[practice] appium settings app is not running after 5000ms](/img/3c/5a7544561231a15a4bb5cfa9e102b3.png)
[practice] appium settings app is not running after 5000ms

Katalon框架测试web(二十)自定义关键字以及上传弹窗操作
随机推荐
JSON模块、hashlib、base64
Compareto() and equals() methods of BigDecimal class
字符串 & 堆 & 方法区
SQL中的DQL、DML、DDL和DCL是怎么区分和定义的
毕业季 新的开始
ThreadLocal的简单理解
【SemiDrive源码分析】【X9芯片启动流程】32 - DisPlay模块分析 - RTOS侧
Mongo database
Ruoyi integrated building block report (NICE)
[leetcode daily question] [December 19, 2021] 997 Find the town judge
什么是主链系统?
NFT卡牌链游系统开发dapp搭建技术详情
【Qt】connect 语法参考实现
动态库(共享库)的制作和使用
方法重写(Override)
Redis6 一:Nosql引入、Redis可以解决什么问题?
Xshell和Xftp使用教程
MytipartFile与File的相互转换
JS基础4
JS foundation 1-js introduction and operator