Christopher: .NET: DateTime.Parse

Beitrag lesen

Hallo allerseits,

ich bin halb am verzweifeln. Und zwar geht es um die sprachabhaengige
Konvertierung eines Datumsformates, welches unter MySQL als
"DateTime"-Typ hinterlegt ist.
Es moechte mir einfach nicht gelingen.
Hier meine bisherigen Versuche. Jedes try/catch schlaegt fehl!

  
public static DateTime? Parse(string value)  
        {  
            int sucOneTime = -1;  
  
            DateTimeFormatInfo dtInfo = CultureInfo.CurrentCulture.DateTimeFormat;  
  
            // first  
            try  
            {  
                DateTime.Parse(value);  
                sucOneTime = 1;  
            }  
            catch (Exception) { }  
  
            // second  
            try  
            {  
                Convert.ToDateTime(value);  
                sucOneTime = 2;  
            }  
            catch (Exception) { }  
  
            // third  
            try  
            {  
                DateTime.Parse(value, dtInfo);  
                sucOneTime = 3;  
            }  
            catch (Exception) { }  
  
  
            // fourth  
            try  
            {  
                DateTime.Parse(value, CultureInfo.CurrentCulture);  
                sucOneTime = 4;  
            }  
            catch (Exception) { }  
  
            // fifth  
            try  
            {  
                Convert.ToDateTime(value, CultureInfo.CurrentCulture);  
                sucOneTime = 5;  
            }  
            catch (Exception) { }  
  
            // sixth  
            try  
            {  
                Convert.ToDateTime(value, dtInfo);  
                sucOneTime = 6;  
            }  
            catch (Exception) { }  
  
  
            if (sucOneTime <= 0)  
                throw new Exception("bla blub");  
  
  
            return null;  
        }  

Hat einer von euch vielleicht eine Idee wie ich das am besten
bewerkstelligen kann?

Besten Dank schonmal
Christopher

PS: Gab es nicht mal den Themenbereich "ASP"? Oder sind derartige
Fragen hier nicht mehr willkommen?