java yyyy-MM-dd HH:mm:ss
时间: 2024-04-28 21:24:55 浏览: 108
以下是一个Java代码示例,可以将日期格式转换为"yyyy-MM-dd HH:mm:ss"格式:
```java
String format = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
String currentTime = simpleDateFormat.format(new Date());
System.out.println(currentTime);
```
这段代码使用了`SimpleDateFormat`类来定义日期格式,并将当前日期转换为指定格式的字符串。输出结果将是形如"2022-06-06 16:02:31"的字符串。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [JAVA - 时间格式 yyyy-MM-dd HH:mm:ss](https://blog.csdn.net/qq_37978224/article/details/127690663)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [java 时间格式“yyyyMMddHHmmssSSSSSS”的解释](https://blog.csdn.net/Amber_1/article/details/125148962)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [js将日期格式转换为YYYY-MM-DD HH:MM:SS](https://download.csdn.net/download/weixin_38713039/12923244)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]