Java - 日期格式转换器? [英] Java - Date Format converter?
本文介绍了Java - 日期格式转换器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
java是否有任何函数,其中我有一个具有此格式日期的字符串: ddMMyy
或 dd.MM.yy
我希望以另一种格式转换它: dd:MM:yy
Has java any function where I have a String with a date in this form : ddMMyy
or dd.MM.yy
and I want to convert it in another format like: dd:MM:yy
推荐答案
我建议使用两个SimpleDateFormat对象。
I would suggest using two SimpleDateFormat objects for this.
Date date = new SimpleDateFormat("ddMMyy").parse( dateString);
String result = new SimpleDateFormat("dd:MM:yy").format( date );
有关格式,请参阅文档: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
For the format, see the documentation: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
这篇关于Java - 日期格式转换器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文