当前位置:网站首页>Time dependent - format, operation, comparison, conversion
Time dependent - format, operation, comparison, conversion
2022-06-11 01:11:00 【Lingqiu, baigeiwang】
1、 Get the current time
Date currentDate = new Date();
2、 Convert to specified format string
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String currentDateStr = df.format(currentDate);
3、 Get a year of time 、 month 、 Zhou 、 Japan
Calendar ca = Calendar.getInstance();
ca.setTime(currentDate);
int day = ca.get(Calendar.DAY_OF_YEAR);// The day of the year
int week = ca.get(Calendar.WEEK_OF_YEAR);// Weeks of the year
int month = ca.get(Calendar.MONTH)+1;// The first few months 8
int year = ca.get(Calendar.YEAR);// Year value 2021
4、 Compare the size of the two times
1) Law 1 : use Date Of getTime() Function to get the numeric type of time (long), Then compare the size of the two as a number
Date date01 = new Date();
Date date02 = new Date();
if(date01.getTime() > date02.getTime()){
System.out.println("date01 Bigger ");
}else {
System.out.println("date02 Greater than or equal to date01");
}
边栏推荐
- 负载均衡策略图文详解
- Datatemplate in WPF
- Deep copy and shallow copy in golang
- How to ensure the sequence of messages, that messages are not lost or consumed repeatedly
- WPF - timeline class
- 87.(leaflet之家)leaflet军事标绘-直线箭头修改
- [introduction to ROS] - 03 ROS workspace and function pack
- The best creative drum tool: groove agent 5
- Pirate OJ 448 luck draw
- [论文阅读] FixMatch: Simplifying Semi-Supervised Learning with Consistency and Confidence
猜你喜欢
![[introduction to ROS] - 03 ROS workspace and function pack](/img/74/ff9bf9fd4912a02d016f560ac3aebb.png)
[introduction to ROS] - 03 ROS workspace and function pack

Complete uninstallation of MySQL under Linux

Pirate OJ 146 character string
![[paper reading] tganet: text guided attention for improved polyp segmentation](/img/e4/a80615e78b819a50886410cc69146d.png)
[paper reading] tganet: text guided attention for improved polyp segmentation
![[introduction to ROS] - 01 introduction to ROS](/img/6f/67ebb4336b6f7b3a1076b09d871b8e.png)
[introduction to ROS] - 01 introduction to ROS

compiler explorer

compiler explorer

MySQL

87.(leaflet之家)leaflet军事标绘-直线箭头修改

【ROS入门教程】---- 03 ROS工作空间与功能包
随机推荐
Promise
SqlServer中的锁
SqlServer中的鎖
Some idle gossip
Team management | how to improve the thinking skills of technical leaders?
Promise
[paper reading] boostmis: boosting medical image semi supervised learning with adaptive pseudolabeling
[论文阅读] TGANet: Text-guided attention for improved polyp segmentation
[introduction to ROS] - 03 single chip microcomputer, PC host and ROS communication mechanism
87.(leaflet之家)leaflet军事标绘-直线箭头修改
WIN11卸载小组件
CentOS7 实战部署MySQL8(二进制方式)
compiler explorer
zabbix离线安装
五大类型负载均衡的原理场景详解
用data和proc怎么写出这个,不用sql
ion_dma_buf_begin_cpu_access
System interpretation: Authority Design Guide
Clean up the broken artifacts data (.lastUpdated files) and reload the project.问题解决办法
配置化自定义实现1.实现接口,2.自定义配置3.默认配置