DateTime removes trailing zeros from milliseconds

前端 未结 2 1068
攒了一身酷
攒了一身酷 2021-01-28 15:14

My Logger class uses DateTime to print up to millisecond accuracy to logfile, however I notice it keeps removing the training zeros which is rather annoying.

Any ideas

2条回答
  •  醉梦人生
    2021-01-28 15:45

    From The FFF Custom Format Specifier;

    The "FFF" custom format specifier represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value. However, trailing zeros or three zero digits are not displayed.

    You can use lower case fff specifier instead.

提交回复
热议问题