时间格式_java

@Test
    public void testDate(){
        Date date=new Date();
        System.out.println(date);
        /*日期格式*/
        DateFormat df1=DateFormat.getDateInstance();
        System.out.println(df1.format(date));
        /*时间格式*/
        DateFormat df2=DateFormat.getDateTimeInstance();
        System.out.println(df2.format(date));
        /*日期 时间格式*/
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");

        System.out.println(sdf.format(date));
    }

  

原文地址:https://www.cnblogs.com/yachao1120/p/11756825.html