DateTime从毫秒中删除尾随零 [英] DateTime removes trailing zeros from milliseconds

查看:75
本文介绍了DateTime从毫秒中删除尾随零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Logger类使用DateTime打印到日志文件的毫秒精度,但是我注意到它一直在删除训练零,这很烦人。

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 on how to solve this?

w.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.FFF") + " [" + Thread.CurrentThread.ManagedThreadId + "]" + " [INFO] " + logMessage);

2016-03-25 20:25:14.692 [8] [INFO] OUTGOING MESSAGE : test
2016-03-25 20:25:18.1 [8] [INFO] OUTGOING MESSAGE : test
2016-03-25 20:25:18.121 [11] [INFO] INCOMING MESSAGE : testReply


推荐答案

.fff 。案件很重要。我在这里为您推荐了出色的文档: https://msdn.microsoft.com/library/8kb3ddd4

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

这篇关于DateTime从毫秒中删除尾随零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆