Skip to content

DateTimePicker lose leading 0 in milliseconds when lose focus. #1796

Description

@konstantine2121

Error location

https://github.com/xceedsoftware/wpftoolkit/blob/master/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimeUpDown/Implementation/DateTimeParser.cs

DateTimeParser.cs

private static string ComputeDateTimeString( string dateTime, string format, DateTime currentDate, CultureInfo cultureInfo, bool autoClipTimeParts )

//Has error here.
string millisecondsPart = currentDate.Millisecond.ToString();

Case

If picker has dateTime value like this '28.04.2025 16:26:16.080'

millisecondsPart = "80";

We have lost leading 0.

in the end we have a result like this '28.04.2025 16:26:16.80'

'28.04.2025 16:26:16.80' == '28.04.2025 16:26:16.800'
'28.04.2025 16:26:16.80' != '28.04.2025 16:26:16.080'

Summary

Control lost focus and value changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions