2013-11-25 48 views

回答

3

您可以使用SimpleDateFormat#parse()将某个特定模式的字符串解析为日期。

String oldstring = "04112013"; 
Date date = new SimpleDateFormat("ddMMyyyy").parse(oldstring); 

使用SimpleDateFormat#format()将日期格式化为某个特定模式的字符串。

String newstring = new SimpleDateFormat("yyyy.MM.dd").format(date); 
System.out.println(newstring); 

我希望它有帮助。

+0

哦,我的天啊! ty告诉我! :) – ZaoTaoBao

+0

没有probs ......;) – MadProgrammer

+0

任何其他解决方案 – WSDL

相关问题