Java - Date Format converter? [duplicate]

醉酒当歌 提交于 2019-12-02 23:37:24

问题


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


回答1:


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 );

For the format, see the documentation: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html



来源:https://stackoverflow.com/questions/31628047/java-date-format-converter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!