DateTime.Parse problem with Time Format using period

G

Guest

Hi

I am having a problem formatting a string when the time is in format
hh.mm.ss - used in Europe

Parse seems ok when the date uses "/" or "." as seperator
but I get an exception when time uses "." as seperator as used in Europe

I have US regional setting and I have tried switching my regional setting to
Europe
with no luck

Any ideas on what I an doing wrong???

Thanks

DateTime dt = DateTime.Parse("10/10/2007" + " " + "12:10:00"); --> OK
DateTime dt = DateTime.Parse("10.10.2007" + " " + "12:10:00"); --> OK


DateTime dt = DateTime.Parse("10.10.2007" + " " + "12.10.00"); -->Problem
DateTime dt = DateTime.Parse("10/10/2007" + " " + "12.10.00"); -->Problem

Exception
String was not recognized as a valid DateTime.
 
G

Guest

hi sippyuconn ,
ur using this format in time( 12.10.00 )-->ok
Actualy we can't use that format ,we can represent ( 12:10:00 )
then only it will run .
ok
 
O

Ollie Riches

you use a DateTimeFormatInfo object, something like:

string str1 = "10/10/2007" + " " + "12.10.00";
DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
dtfi.TimeSeparator = ".";
DateTime dt1 = DateTime.Parse(str1, dtfi);

HTH

Ollie Riches
 
S

Stoitcho Goutsev \(100\)

sippyuconn,
Why do you think 12.10.00 is valid time format in Europe?
European countries uses ':' for time separator. '.' can be used only to show
fractions of a second.
 
T

Tim Van Wassenhove

sippyuconn schreef:
Parse seems ok when the date uses "/" or "." as seperator
but I get an exception when time uses "." as seperator as used in Europe

Use DateTime.ParseExact instead?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top