代码如下:
import java.util.*;
import java.text.*;
public class TestCalendar {
public static void main(String[] args) {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日");
try {
Date d = sdf1.parse("2015-01-05");
System.out.println("转换之前:" + sdf1.format(d));
System.out.println("转换之后:" + sdf2.format(d));
} catch (Exception e) {
e.getStackTrace();
}
}
}
运行结果: