java 17 - 日期周期&数字格式化
直接上效果
public static void main(String[] args) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("B", Locale.CHINA);
System.out.println(dtf.format(LocalTime.of(8, 0)));
System.out.println(dtf.format(LocalTime.of(13, 0)));
System.out.println(dtf.format(LocalTime.of(20, 0)));
System.out.println(dtf.format(LocalTime.of(23, 0)));
System.out.println(dtf.format(LocalTime.of(0, 0)));
NumberFormat fmt = NumberFormat.getCompactNumberInstance(Locale.CHINA, NumberFormat.Style.SHORT);
System.out.println(fmt.format(1000));
System.out.println(fmt.format(100000));
System.out.println(fmt.format(1000000));
System.out.println(fmt.format(10000000));
System.out.println(fmt.format(100000000));
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
打印
上午
下午
晚上
晚上
午夜
1,000
10万
100万
1000万
1亿
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
如果是英文语言环境则是
in the morning
in the afternoon
in the evening
at night
midnight
1K
100K
1M
10M
100M
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
上次更新: 2024/01/11 17:06:16