Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
When setting the format of a datepicker to "MM/dd/yyyy" the date is shown as 02-20-2017.
The language on the device is set to Dutch. The default date format for the Dutch language is: dd-MM-yyyy.
So the order of day and month is changed with the custom format, but not the separator.
It is not a bug, but a feature. The / is also a special formatting character. If you want the literal character, you have to escape it with a \ like @"MM\/dd\/yyyy"
Just to clarify, the issue is that the default separator is used instead of "/", correct?
Can you try the suggestion from comment 1 and escape the '/' character to see if it helps? If it does not, please attach a reproduction project to the report so we can look into this further. Thanks!
When the format is given as picker.Format = "MM/dd/yyyy";
The date is shown as 03-07-2017 (on a device with dutch language settings).
The workaround picker.Format = @"MM\/dd\/yyyy"; does give the correct date of 03/07/2017.
But I don't see how this can be a feature. Custom date formats are always given as e.g. "MM/dd/yyyy". And the formats are in resource files, dependent on the selected language. For the workaround I have to add an extra resource for date pickers, which increases the change of missing that format when something changes.
This seems to have a correct answer by Jimmy
The workaround as suggested by Gert Jan works for now.
But I don't see that this can be a feature. As I said, custom date formats are always entered as "MM/dd/yyyy". So the behavior of the datepicker is inconsistent.
This bug should not have the resolved status.
The current behaviour is exactly as documented. That is why it is not a bug, but a feature.
"The "/" custom format specifier"
"Using the Escape Character"
As also mentioned here, because the "/" character is not escaped it is interpreted as a format specifier that is replaced by the current culture date separator which is "-" in this case since the device language is Dutch.
So Gert is correct in that you have to escape the character in order for it to be used as the date separator regardless of culture. As this is all handled by .Net and not Xamarin.Forms, I will go ahead and close this as answered. Thanks!