/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateTest {
public static void main(String[] args) throws ParseException {
String s = "2008-08-08";
System.out.println("初始值:-----------" + s);
String pattern = "yyyy-MM-dd";
SimpleDateFormat df = new SimpleDateFormat(pattern);
Date date = df.parse(s);
System.out.println("格式化--------:" + date);
//exap:Mon Sep 21 16:20:50 CST 2009
Date d = new Date();
System.out.println("初始值字符串----------:" + d);
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy年MM月dd日");
System.out.println("解决后的字符串----------:" + simpleDateFormat.format(d));
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateTest {
public static void main(String[] args) throws ParseException {
String s = "2008-08-08";
System.out.println("初始值:-----------" + s);
String pattern = "yyyy-MM-dd";
SimpleDateFormat df = new SimpleDateFormat(pattern);
Date date = df.parse(s);
System.out.println("格式化--------:" + date);
//exap:Mon Sep 21 16:20:50 CST 2009
Date d = new Date();
System.out.println("初始值字符串----------:" + d);
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy年MM月dd日");
System.out.println("解决后的字符串----------:" + simpleDateFormat.format(d));
}
}