在Java中格式化日期需要帮助 [英] Help needed in formatting date in Java
本文介绍了在Java中格式化日期需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下日期作为字符串格式。
Hi I have the following date as String format.
输入
2010-04-20 05:34:58.0
输出我想要的字符串像
Output I want the string like
20, Apr 2010
有人可以告诉我如何做吗?
Can someone tell me how to do it ?
推荐答案
尝试这个:
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);
这篇关于在Java中格式化日期需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文