首页 > 试题广场 >

假设当前时间是2018-08-20,晚上19:08,星期一,

[单选题]
假设当前时间是2018-08-20,晚上19:08,星期一,则下面代码输出为:
public class Test {   
   public static void main(String[] args) {   
    Date date=new Date();
    System.out.printf("%tD%n",date);   
     }   
   }    
   

  • 2018/8/20
  • 08/20/18
  • 2018/8/20 19:08:00
  • 08/20/18 19:08:00
1.%n是指换行符。有点奇怪(\n是换行符).
2.对于时间的转换符.
   tD        美国格式的日期   08/20/18
   tT        24小时时间           13:20:18
   tY        四位的年               2020
更多的时间转换符:https://blog.csdn.net/junshuaizhang/article/details/40153147 (转载).
发表于 2020-02-15 13:22:00 回复(1)
public class Test {   
	   public static void main(String[] args) {   
	    Date date=new Date();
	    System.out.printf("%tD%n",date);    //01/18/20
	     }   
	   }    


发表于 2020-01-18 19:42:30 回复(0)