java.sql.Date类型时间获取当前时间,精确到时分秒的方法
- 提问者网友:留有余香
- 2021-05-01 06:58
- 五星知识达人网友:一秋
- 2021-05-01 08:38
java.sql.Timestamp time=new java.sql.Timestamp(datetime.getTime());
- 1楼网友:话散在刀尖上
- 2021-05-01 10:51
- 2楼网友:你可爱的野爹
- 2021-05-01 10:16
Date date = new Date(); DateFormat df1 = DateFormat.getDateInstance();//日期格式,精确到日 System.out.println(df1.format(date)); DateFormat df2 = DateFormat.getDateTimeInstance();//可以精确到时分秒 System.out.println(df2.format(date)); DateFormat df3 = DateFormat.getTimeInstance();//只显示出时分秒 System.out.println(df3.format(date)); DateFormat df4 = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL); System.out.println(df4.format(date)); DateFormat df5 = DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG); System.out.println(df5.format(date)); DateFormat df6 = DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT);
System.out.println(df6.format(date)); DateFormat df7 = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM);
System.out.println(df7.format(date));