java中把字符串“20110101”转换为字符串"2011-01-01"的技巧
import java.text.ParseException; import java.text.SimpleDateFormat; public static void main(String[] args) { String str = "20110101"; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd"); try { System.out.println(format1.format(format.parse(str))); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } }输出结果为2011-01-01
java中把字符串“20110101”转换为字符串"2011-01-01"的技巧
原文地址:http://blog.csdn.net/wangcunhuazi/article/details/43023861