Java 更改日期格式

import java.util.*;
import java.text.*;

public class TestDateFormat {
    public  static void main(String[] args)
    {
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日");
        
        try
        {
            Date d = sdf2.parse("2003年03月15日");
            System.out.println(sdf1.format(d));
        }catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
    }

 

posted @ 2017-05-25 08:39  羊羊羊🐑  Views(627)  Comments(0Edit  收藏  举报