using namespace System; using namespace System::Globalization; int main() { // Assume the current culture is en-US. // The date is February 16, 1992, 12 hours, 15 minutes and 12 seconds. String^ myDateTimeValue = "2/16/1992 12:15:12"; DateTime myDateTime = DateTime::Parse( myDateTimeValue ); Console::WriteLine( "1) myDateTime = {0}", myDateTime ); // Reverse month and day to conform to a different culture. // The date is February 16, 1992, 12 hours, 15 minutes and 12 seconds. IFormatProvider^ culture = gcnew CultureInfo( "fr-FR",true ); String^ myDateTimeFrenchValue = " 16/02/1992 12:15:12"; DateTime myDateTimeFrench = DateTime::Parse( myDateTimeFrenchValue, culture, DateTimeStyles::NoCurrentDateDefault ); Console::WriteLine( "2) myDateTimeFrench = {0}", myDateTimeFrench ); // The date is February 16, 1992, 12 hours, 15 minutes and 12 seconds. array^expectedFormats = {"G","g","f","F"}; myDateTimeFrench = DateTime::ParseExact( myDateTimeFrenchValue, expectedFormats, culture, DateTimeStyles::AllowWhiteSpaces ); Console::WriteLine( "3) myDateTimeFrench = {0}", myDateTimeFrench ); } /* This example yields the following results: 1) myDateTime = 2/16/1992 12:15:12 PM 2) myDateTimeFrench = 2/16/1992 12:15:12 PM 3) myDateTimeFrench = 2/16/1992 12:15:12 PM */