且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Java中格式化日期需要帮助

更新时间:2023-01-19 23:26:25

尝试这个:

DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");  
DateFormat outputFormat = new SimpleDateFormat("dd, MMM yyyy");

Date yourDate = inputFormat.parse("2010-04-20 05:34:58.0");
String formattedDate = outputFormat.format(yourDate);