Wed Dec 27 00:00:00转化为年月日时分秒java
时间: 2023-12-30 07:24:03 浏览: 134
spring-demo-xuzhqii_java_
以下是将"Wed Dec 27 00:00:00"转化为年月日时分秒的Java代码示例:
```java
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
public static void main(String[] args) {
String dateString = "Wed Dec 27 00:00:00";
DateFormat inputFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss");
DateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date date = inputFormat.parse(dateString);
String formattedDate = outputFormat.format(date);
System.out.println(formattedDate);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
```
输出结果为:2017-12-27 00:00:00
阅读全文