JAVA学习笔记API之DateFormat

1.创建DateFormat对象

DateFormat df=new SimpleDateFormat("yyyy-MM-dd");//指定格式
        Date date=new Date(1607616000000L);
        String str_time=df.format(date);
        System.out.println(str_time);

2.将date转换成String对象

Date date =new Date(1607616000000L);
        DateFormat df=new SimpleDateFormat("yyyy年MM月dd日");
        String str=df.format(date);//格式化

3.将String对象转换成Date

String str="2019年03月13日";

DateFormate df=new simpleFormat("yyyy年MM月dd日);

Date date=df.parse(str);

猜你喜欢

转载自blog.csdn.net/lieanwan2780/article/details/88523989
今日推荐