当前位置:网站首页>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();
}
}
边栏推荐
猜你喜欢
Markdown -- basic usage syntax
Katalon当中的output使用方法
Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
DlhSoft Kanban Library for WPF
MySQL general binary installation method
移动命令
Internet of things application case of wireless module transparent transmission technology
sentinel
利用soapUI获取freemarker的ftl文件模板
AGCO AI frontier promotion (6.28)
随机推荐
Compression and decompression
Summary of spatial temporal time series prediction modeling methods
JS基础3
一套十万级TPS的IM综合消息系统的架构实践与思考
使用logrotate对宝塔的网站日志进行自动切割
线程和线程池
时间戳和date转换「建议收藏」
MySQL(一)
Mongo数据库
零基础自学SQL课程 | IF函数
Redis数据库
Compareto() and equals() methods of BigDecimal class
毕业季 新的开始
Metersphere实现UI自动化元素不可点击(部分遮挡)
李宏毅《机器学习》丨7. Conclusion(总结)
MytipartFile与File的相互转换
Excel导入导出便捷工具类
什么是DAPP系统发展与解析理解
Blue Bridge Cup Maze (dfs+ backtracking)
【Qt】connect 语法参考实现