SimpleDateFormat format millisecond

In the development, certain scenarios need to be formatted is the time to the millisecond accuracy and the like, such as creating a file name, etc., codes are as follows:

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
System.out.println("======"+sdf.format(new Date()));
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmssSSSXXX");
System.out.println("======"+sdf1.format(new Date()));
SimpleDateFormat sdf11 = new SimpleDateFormat("yyyyMMddHHmmssSSSSSSSSS");
System.out.println("======"+sdf11.format(new Date()));
SimpleDateFormat sdf111 = new SimpleDateFormat("yyyyMMddHHmmssSSSSSSSSSXXX");
System.out.println("======"+sdf111.format(new Date()));
System.out.println("======"+System.currentTimeMillis());


输出结果:
======20200404011237062
======20200404011237063+08:00
======20200404011237000000063
======20200404011237000000064+08:00
======1585933957064
 

 

Guess you like

Origin www.cnblogs.com/xuzhujack/p/12630107.html