Parsing a DateTime from String in Metro app RRS feed

  • Question

  • I am trying to use System::DateTime::Parse, but it it not working.  Here is my wrapper class:

    #pragma once
    #using <mscorlib.dll>
    class ISODateParser
    	static Windows::Globalization::Calendar^ ParseISODate(Platform::String^ ISODate)
    		Windows::Foundation::DateTime dateTimeRepresentation;
    		dateTimeRepresentation.UniversalTime = System::DateTime::Parse(ISODate).ToUniversalTime().ToBinary();
    		Windows::Globalization::Calendar^ retVal = ref new Windows::Globalization::Calendar();
    		return retVal;

    System::DateTime::Parse will not compile, and it gives me the error:

    error C2683: 'dynamic_cast' : 'System::Object' is not a polymorphic type

    What is the correct way to use this method?  I have tried using System::DateTime::ParseExact and System::Convert::ToDateTime as well.

    Can these .NET methods be used in a Windows Metro App?  I do not see any method to get a Windows::Foundation::DateTime or Windows::Globalization::Calendar from a String representation.  I suppose I may just have to write my own parser implementation.

    Sunday, April 1, 2012 5:17 PM