File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22 * @由于个人水平有限, 难免有些错误, 还请指点:
33 * @Author: cpu_code
44 * @Date: 2020-07-12 12:03:11
5- * @LastEditTime: 2020-09-16 09:04:19
5+ * @LastEditTime: 2020-09-16 09:07:44
66 * @FilePath: \java\README.md
77 * @Gitee: [https://gitee.com/cpu_code](https://gitee.com/cpu_code)
88 * @Github: [https://github.com/CPU-Code](https://github.com/CPU-Code)
@@ -223,6 +223,7 @@ java编程基础 面向对象 javaAPI 集合 IO GUI JD8C 多线程 网络编程
223223- [x] [ date6__ Calendar] ( javaAPI/date/date6.java )
224224- [x] [ date7__ Calendar_get] ( javaAPI/date/date7.java )
225225- [x] [ date8__ Calendar_set] ( javaAPI/date/date8.java )
226+ - [x] [ date9__ Calendar_add] ( javaAPI/date/date9.java )
226227
227228-----------------------
228229
Original file line number Diff line number Diff line change 1+ /*
2+ * @由于个人水平有限, 难免有些错误, 还请指点:
3+ * @Author: cpu_code
4+ * @Date: 2020-09-16 09:07:57
5+ * @LastEditTime: 2020-09-16 09:13:44
6+ * @FilePath: \java\javaAPI\date\date9.java
7+ * @Gitee: [https://gitee.com/cpu_code](https://gitee.com/cpu_code)
8+ * @Github: [https://github.com/CPU-Code](https://github.com/CPU-Code)
9+ * @CSDN: [https://blog.csdn.net/qq_44226094](https://blog.csdn.net/qq_44226094)
10+ * @Gitbook: [https://923992029.gitbook.io/cpucode/](https://923992029.gitbook.io/cpucode/)
11+ */
12+ package javaAPI .date ;
13+
14+ import java .util .Calendar ;
15+
16+ public class date9 {
17+ public static void main (String [] args ) {
18+ Calendar cal = Calendar .getInstance ();
19+ // 设置年
20+ int year = cal .get (Calendar .YEAR );
21+ // 设置月
22+ int month = cal .get (Calendar .MONTH ) + 1 ;
23+ // 设置日
24+ int dayOfMonth = cal .get (Calendar .DAY_OF_MONTH );
25+
26+
27+ System .out .println (year + "年" + month + "月" + dayOfMonth + "日" );
28+
29+ cal .add (Calendar .DAY_OF_MONTH , 2 );
30+ cal .add (Calendar .YEAR , -3 );
31+
32+ // 设置年
33+ year = cal .get (Calendar .YEAR );
34+ // 设置月
35+ month = cal .get (Calendar .MONTH ) + 1 ;
36+ // 设置日
37+ dayOfMonth = cal .get (Calendar .DAY_OF_MONTH );
38+
39+ System .out .println (year + "年" + month + "月" + dayOfMonth + '日' );
40+ }
41+ }
42+
43+ /*
44+ 2020年9月16日
45+ 2017年9月18日
46+ */
You can’t perform that action at this time.
0 commit comments