Problem with DateTime.Parse

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tobias Olbort

    #1

    Problem with DateTime.Parse

    Hello,

    why does this not work (the OS runs with german settings):

    DateTimeFormatI nfo dtFI = new DateTimeFormatI nfo();

    dtFI.FullDateTi mePattern = "ddd MMM dd HH:mm:ss yyyy";
    dtFI.Abbreviate dDayNames = new string[] {"Mon", "Tue", "Wed",
    "Thu", "Fri", "Sat", "Sun"};
    dtFI.Abbreviate dMonthNames = new string[] {"Jan", "Feb", "Mar",
    "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
    return DateTime.Parse( "Fri Aug 01 09:03:43 2003", dtFI);

    Thanks for any suggestion.

    Tobias
  • Dmitriy Lapshin [C# / .NET MVP]

    #2
    Re: Problem with DateTime.Parse

    Hello Tobias,

    Try a simpler solution:

    System.IFormatP rovider format =
    new System.Globaliz ation.CultureIn fo("en-US", true);

    return DateTime.Parse( "Fri Aug 01 09:03:43 2003", format);

    --
    Dmitriy Lapshin [C# / .NET MVP]
    X-Unity Unit Testing and Integration Environment

    Deliver reliable .NET software

    "Tobias Olbort" <Tobias@Olbort. de> wrote in message
    news:bc32ad77.0 308080427.6dcf7 130@posting.goo gle.com...[color=blue]
    > Hello,
    >
    > why does this not work (the OS runs with german settings):
    >
    > DateTimeFormatI nfo dtFI = new DateTimeFormatI nfo();
    >
    > dtFI.FullDateTi mePattern = "ddd MMM dd HH:mm:ss yyyy";
    > dtFI.Abbreviate dDayNames = new string[] {"Mon", "Tue", "Wed",
    > "Thu", "Fri", "Sat", "Sun"};
    > dtFI.Abbreviate dMonthNames = new string[] {"Jan", "Feb", "Mar",
    > "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
    > return DateTime.Parse( "Fri Aug 01 09:03:43 2003", dtFI);
    >
    > Thanks for any suggestion.
    >
    > Tobias[/color]

    Comment

    • Tobias Olbort

      #3
      Re: Problem with DateTime.Parse

      Hello Dmitriy,

      thanks for your reply.

      With the addition of the pattern it works now fine.

      Like this:

      return DateTime.ParseE xact("Fri Aug 01 09:03:43 2003", "ddd MMM dd
      HH:mm:ss yyyy", new System.Globaliz ation.CultureIn fo("en-US", true));

      Tobias

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...