Reputation: 4152
I have an sql query that saves a list of Dates (public holidays) to the database. This works fine on Windows and Android, but it fails on MonoTouch. It fails in the line below.
DateTime.Parse("01/01/2013").Date
It seems that MonoTouch is not able to parse this date. I know how to fix it by creating the DateTime object directly, but I just want to know if there is something that I am missing or is it a bug in MonoTouch?
I fixed it by instantiating the DateTime
object directly like this:
new DateTime(2013,01,01)
Upvotes: 1
Views: 99
Reputation: 89102
This is happening because you have your culture set to something that does not recognize "01/01/2013" as a default date format. Your code works for me, but I am using "en-us" culture where MM/DD/YYYY is the standard format.
You can use Date.ParseExact() and specify a date format to override whatever the default for your culture is.
Upvotes: 3