当前位置:网站首页>Calendar日历类
Calendar日历类
2022-07-23 12:04:00 【杀手不太冷!】
Calendar日历类
初始化
Calendar日历类是初始化对象用的是Calendar.getInstance()方法,如下图:

Calendar日历中的Day,Year,Day_Of_Year等属性
如果我们想要得到一个日期对应的是第几年,或者这个日期对应的是一年中的第几天,或者是一年中的第几周,或者是一个月中的第几天,我们都可以直接使用Calendar对象的get方法进行获取,如下图:

Calendar类中有很多属性,如下图:

Calendar主动设置日期
Calendar有很多set重载函数,设置日期的时候可以只设置年月日如下图:

也可以设置年月日时分秒,如下图:

但是需要注意的是,我们的月份计算的时候是从0进行计算的,也就是说我们如果想要设置1月的时间,我们把month这个参数设置为0,如下图:
Calendar类型和Date类型的转换
Date类型如何转换为Calendar类型?

Calendar类型转换为Date类型?

边栏推荐
- After effects tutorial, how to create animation in after effects?
- SOC的第一个Hello_World实验
- [attack and defense world web] difficulty Samsung 9-point introductory question (middle): ics-05, easytornado
- Mailbox communication-
- W3C introduces decentralized identifier as web standard
- 七、jmeter发出请求的逻辑
- 死锁的3种处理策略
- EmguCV录制视频
- FMDB的封装与使用
- 激光共聚焦如何选择荧光染料
猜你喜欢

After effects tutorial, how to create animation in after effects?

LeetCode高频题:最少经过几次操作可以使数组变为非降序状态

Éléments de base de la validation des haricots - 04

Bean Validation入门篇----02

(Zset) how is the underlying layer of redis stored with a hop table

ECS remote monitoring

死锁的3种处理策略
![[operation and maintenance] SSH tunneling relies on the 22 port of SSH to realize the interface service of accessing the remote server](/img/4a/7156470e8d96c7709001bac88e872c.png)
[operation and maintenance] SSH tunneling relies on the 22 port of SSH to realize the interface service of accessing the remote server

First hello of SOC_ World experiment

Design idea of initializing page input parameters
随机推荐
[cloud native] continuous integration and deployment (Jenkins)
Day14 function module
Don't want dto set. Dto can be written like this
MySQL 灵魂 16 问,你能撑到第几问?
ICML 2022 | sparse double decline: can network pruning also aggravate model overfitting?
为什么要造一个 UILabel ?( 复习两丫技术 )
Of the 24 almost inevitable JVM interview questions, I only know 7. How many can you answer?
【云原生】持续集成和部署(Jenkins)
JS filter / replace sensitive characters
W3C introduces decentralized identifier as web standard
redis 主从复制
How to become an elegant Hardware Engineer?
The difference between deadlock, hunger and dead cycle
Vulnstack red sun-4
W3C 推出去中心化标识符作为 Web 标准
ORA-01654错误:表空间满了,插入失败
How beautiful can VIM be configured?
Bean Validation起源篇----01
Vim到底可以配置得多漂亮?
Cover - computer knowledge guide