DateTime removes trailing zeros from milliseconds

前端 未结 2 1074
攒了一身酷
攒了一身酷 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.

    0 讨论(0)
  • 2021-01-28 15:53

    .fff. Case matters. I refer you to the excellent documentation here: https://msdn.microsoft.com/library/8kb3ffffd4

    0 讨论(0)
提交回复
热议问题