Date endDay =new Date()
时间: 2024-06-14 17:04:00 浏览: 124
以下是将Date类型转换为String类型和Calendar类型的示例代码:
1. 将Date类型转换为String类型:
```java
Date date = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String time = df.format(date);
System.out.println(time); // 输出:2022-01-01 12:00:00
```
2. 将Date类型转换为Calendar类型:
```java
Date date = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
```
阅读全文