Bug 20434 - DateTime.ParseExact always throws System.FormatException: Invalid format string
Summary: DateTime.ParseExact always throws System.FormatException: Invalid format string
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: master
Hardware: Macintosh Mac OS
: Normal major
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-06-06 14:09 UTC by Frank A. Krueger
Modified: 2014-06-09 08:26 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description Frank A. Krueger 2014-06-06 14:09:07 UTC
DateTime.ParseExact ("30-12-2011", "MM-dd-YYYY", CultureInfo.InvariantCulture)

No matter what format I put in, DateTime.ParseExact throws:

System.FormatException: Invalid format string
  at System.DateTime.ParseExact (System.String s, System.String[] formats, IFormatProvider provider, DateTimeStyles style) [0x00000] in <filename unknown>:0 
  at System.DateTime.ParseExact (System.String s, System.String format, IFormatProvider provider, DateTimeStyles style) [0x00000] in <filename unknown>:0 
  at System.DateTime.ParseExact (System.String s, System.String format, IFormatProvider provider) [0x00000] in <filename unknown>:0 

There is the same problem with TryParseExact.

I have tried most of the examples from: http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx and none work.
Comment 1 Udham Singh 2014-06-09 07:22:34 UTC
I have tried to reproduce this issue but for me methods "ParseExact" and "TryParseExact" are working fine. Please refer the screencast : http://screencast.com/t/5gSs3VECiQp6

Please let me know if I have missed anything to reproduce this issue.

Environment info: 

=== Xamarin Studio ===

Version 5.1 (build 415)
Installation UUID: 561c7a69-0a91-4bae-ad7c-f0c79d594337
	Mono 3.6.0 ((no/8dcee6c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 306000000

=== Xamarin.Android ===

Version: 4.12.4 (Trial Edition)
Android SDK: /Users/tajinder/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: f293050
Build date: 2014-06-05 09:22:30-0400

=== Xamarin.Mac ===


=== Build Information ===

Release ID: 501000415
Git revision: 952688cfc5132fcd10f0218b8991114849fe0dd6
Build date: 2014-06-08 13:37:58-04
Xamarin addins: 2c39ca1ce8e771ebfd5bfb8cf699d1f2cfd9a4ac

=== Operating System ===

Mac OS X 10.8.4
Darwin Tajinders-iMac.local 12.4.2 Darwin Kernel Version 12.4.2
    Mon Jun 17 18:00:12 PDT 2013
    root:xnu-2050.45.8~1/RELEASE_X86_64 x86_64
Comment 2 Rolf Bjarne Kvinge [MSFT] 2014-06-09 08:26:08 UTC
The Y's should be lower case:


Also note that you're parsing as month=30, day=12.

This works fine:

 DateTime.ParseExact ("30-12-2011", "dd-MM-yyyy", CultureInfo.InvariantCulture)