格式化类
1、日期格式化类
java.text.SimpleDateFormat简单日期格式化
![image-20220714161720336](Img\image-20220714161720336.png)
按照指定的格式来格式化Date对象
```java
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss E");
//格式化日期返回对应格式的字符串,一般用于显示
String s = sdf.format(date1);
System.out.println("s = " + s);
//解析字符串,返回Date对象(必须格式一致)
Date date2 = sdf.parse("2025年10月1日 00:00:00 星期四");
System.out.println("date2 = " + date2);
```
结果演示
```
s = 2022年07月14日 15:17:05 星期四
```
2、数字格式化
java.text.DecimalFormat
可以格式化数字
支持的符号
![image-20220714162511859](Img\image-20220714162511859.png)
```java
public class Demo04 {
public static void main(String[] args) throws ParseException {