How to include milliseconds in a DateTime user setting?

I have the following user setting defined in app.config:

<userSettings>
    <MyProject.Properties.Settings>
        <setting name="LastProcessedDate" serializeAs="String">
            <value>07/06/2010 13:05:10</value>
        </setting>
    </MyProject.Properties.Settings>
</userSettings>

Is there a way to specify that this setting should be serialized with the milliseconds - e.g. 07/06/2010 13:05:10.181 - so that I can accurately compare it to a SQL Server datetime field?

Answers


Unfortunately, you can't save millisecond values in settings. Deep down in the System.Configuration.SettingsPropertyValue.ConvertObjectToString method the DateTime value is converted to a string using the TypeConverter.ConvertToInvariantString method which doesn't produce milliseconds.

If you really want that level of accuracy and you must save it in the user settings, you should use a different parameter type like string using a custom format that includes milliseconds. None of the standard time formats includes milliseconds.


You could try storing it as an Int64, which would preserve the entire value of the DateTime without any formatting issues or loss of fidelity.


Need Your Help

3 Separate Text Alignments on one UILabel

iphone ios uilabel core-text nsattributedstring

I have UILabel that I wish to split into 3 columns per say.

How to change InfiniteScrollAdapter animation image

java infinite-scroll codenameone

The default image for InfiniteProgress is an ugly looking icon from Google material. I have a collection of some fonticons and I will like to set the InfiniteScrollAdapter's animation image to one of