-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathjava-time-LocalDateTime.java
More file actions
53 lines (43 loc) · 1.2 KB
/
java-time-LocalDateTime.java
File metadata and controls
53 lines (43 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-------------------------
LocalDateTime |
-------------------------
# 表示时间+日期
# 构造(通过静态方法)
LocalDateTime LocalDateTime.now();
* 获取系统当前时间
* 2016-05-24T22:41:30.852
LocalDateTime LocalDateTime.of(int year,int month,int dayOfMonth,int hour,int minute,int second);
* 根据指定的日期和时间返回LocalDateTime对象
LocalDateTime parse(CharSequence text, DateTimeFormatter formatter);
* 根据 formatter 来格式出 LocalDateTime 对象
-------------------------
LocalDateTime-api |
-------------------------
# 读取相关
int getYear();
* 返回日期中的年份
int getMonth();
* 返回日期中的月份
int getDayOfMonth();
* 返回月份中的第几天
int getHour();
* 返回小时
int getMinute();
* 返回分钟
int getSecond();
* 返回秒
# 设置相关
LocalDateTime withDayOfMonth(int num);
* 设置月中的天数
LocalDate toLocalDate();
* 转换为 LocalDate 对象
LocalTime toLocalTime();
* 转换为 LocalTime 对象
LocalDateTime plusYears(int year);
* 添加多少年
LocalDateTime plusMonths(int month);
* 添加多少个月
* '还有很多添加时分秒的API,都一样'
# 格式化相关
String formart(DateTimeFormatter matter);
* 根据 DateTimeFormatter 返回被格式化后的时间字符串