SimpleDateFormat设置为UTC毫秒
时间: 2023-11-22 22:12:52 浏览: 148
毫秒数转为时间格式
要将SimpleDateFormat设置为UTC毫秒,可以使用以下代码:
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
format.setTimeZone(TimeZone.getTimeZone("UTC"));
这将创建一个SimpleDateFormat对象,并将其格式设置为"yyyy-MM-dd HH:mm:ss.SSS",表示年份-月份-日期 小时:分钟:秒.毫秒,并将时区设置为UTC。这样,您可以使用format对象将日期和时间以UTC毫秒的格式解析或格式化。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [将UTC日期转换为毫秒](https://blog.csdn.net/weixin_39627408/article/details/111811251)[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: 50%"]
- *2* *3* [关于日期:Java – SimpleDateFormat格式化程序,以毫秒为单位返回纪元时间](https://blog.csdn.net/weixin_27207591/article/details/114556167)[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: 50%"]
[ .reference_list ]
阅读全文