By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,491 Members | 1,186 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,491 IT Pros & Developers. It's quick & easy.

Weird CultureInfo - DateTime.Parse() and Decimal.Parse()

P: n/a
Hello Everyone,

I observed something strange in some quick testing code:

void Button1Click(object sender, System.EventArgs e)
{
CultureInfo culture = new CultureInfo("th-TH", false);

tbxDisplayResult.Text = DateTime.Parse(tbxInputArea.Text,
culture).ToString("yyyy MMMMMMMMMM dd");
}
with tbxInputArea.Text of "10.9.2006",
tbxDisplayResult.Text is displayed as "1463 September 10".

Thailand might have taken huge steps backwards over the past 24 hours, but
I doubt it's steps of that magnitude, isn't it?

================================================== ========

void Button1Click(object sender, System.EventArgs e)
{
CultureInfo culture = new CultureInfo("ms-MY", false);

tbxDisplayResult.Text = Decimal.Parse(tbxInputArea.Text,
culture).ToString("N2");
}

tbxInputArea.Text of "1,973.00" results in a parsing error,
whereas with tbxInputArea.Text of "1.973,00" parsing succeeds.

I doubt that Malaysia uses decimal separators the way the Germans do.
Is that a bug in the framework?

Rico.
Sep 20 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
I doubt that Malaysia uses decimal separators the way the Germans do.
Is that a bug in the framework?

Rico.
You doubt they use decimal separators the wat the Germans do or you know
they don't? How come you call this a bug in the framework when you don't
even know the facts? How about looking at Regional and Language options in
control panel at Malay number format? They indeed use the decimal separators
the way the Germans do. Even if you doubt it.
Sep 20 '06 #2

P: n/a
The results are correct, you're just not interpreting them correctly. See
inline

"Rico" <ra*****@yahoo.comwrote in message
news:Xn****************************@130.133.1.4...
Hello Everyone,

I observed something strange in some quick testing code:

void Button1Click(object sender, System.EventArgs e)
{
CultureInfo culture = new CultureInfo("th-TH", false);

tbxDisplayResult.Text = DateTime.Parse(tbxInputArea.Text,
culture).ToString("yyyy MMMMMMMMMM dd");
}
with tbxInputArea.Text of "10.9.2006",
tbxDisplayResult.Text is displayed as "1463 September 10".

Thailand might have taken huge steps backwards over the past 24 hours, but
I doubt it's steps of that magnitude, isn't it?
For starters your input data is incorrect. Thailand uses '/' as date
separator. Secondly, Parse actually succeedes here (even though you feed it
with invalid data). What you failed to realize is that Thailand uses a
calendar that is offset by 543 years, so Sept 10, 2006 in the Thai calendar
is the same as Sept 10, 1463 in the Gregorian calendar.

void Button1Click(object sender, System.EventArgs e)
{
CultureInfo culture = new CultureInfo("ms-MY", false);

tbxDisplayResult.Text = Decimal.Parse(tbxInputArea.Text,
culture).ToString("N2");
}

tbxInputArea.Text of "1,973.00" results in a parsing error,
whereas with tbxInputArea.Text of "1.973,00" parsing succeeds.

I doubt that Malaysia uses decimal separators the way the Germans do.
Stop doubting and look it up instead (they do in fact use ',' as decimal
seprator).
Is that a bug in the framework?
No

/claes
Sep 20 '06 #3

P: n/a
"Lebesgue" <le******@gmail.comwrote in
>I doubt that Malaysia uses decimal separators the way the Germans do.
Is that a bug in the framework?

Rico.

You doubt they use decimal separators the wat the Germans do or you
know they don't? How come you call this a bug in the framework when
you don't even know the facts? How about looking at Regional and
Language options in control panel at Malay number format? They indeed
use the decimal separators the way the Germans do. Even if you doubt
it.
Does it make you feel good to put me down dude?
Does it satisfy some psychological need of yours to make yourself aware of
how smart you are by virtue of your information gathering skills?

Some information gathering skills to be proud of.. control panel... heh..

I had thought before come here that it was a better idea to ask my friend
who lives and works in Malaysia how things go there, wouldn't you?
My friend's answer was that "1,973.00" was the way they wrote it.

I didn't come here saying that I have found a bug. The answer to the
question I asked seems to be that it's not a bug but just Microsoft
following the 'official' format, even though it's not the only one, or the
most commonly used one on a daily basis.

I could end by giving you the finger and saying "screw you!".. but I won't.
Thank you.

Rico.
Sep 21 '06 #4

P: n/a
"Claes Bergefall" <lo*****@nospam.nospamwrote in
news:#b**************@TK2MSFTNGP04.phx.gbl:
The results are correct, you're just not interpreting them correctly.
See inline
ok.. I'm very much ready to realise and accept that.
For starters your input data is incorrect. Thailand uses '/' as date
separator. Secondly, Parse actually succeedes here (even though you
feed it with invalid data). What you failed to realize is that
Thailand uses a calendar that is offset by 543 years, so Sept 10, 2006
in the Thai calendar is the same as Sept 10, 1463 in the Gregorian
calendar.
Thanks. I had not thought about that.
>tbxInputArea.Text of "1,973.00" results in a parsing error,
whereas with tbxInputArea.Text of "1.973,00" parsing succeeds.

I doubt that Malaysia uses decimal separators the way the Germans do.

Stop doubting and look it up instead (they do in fact use ',' as
decimal seprator).
I said "Malaysia" , not the Malay number format.

In fact, "1,973.00" is the format coming to us from a big-name enterprise
software and they claim that the decimal separators used are as per
expected in the corresponding country, in this case, Malaysia.
But CultureInfo for "ms-MY", says Malay(Malaysia) so the behaviour is
fine.
>Is that a bug in the framework?

No
Thanks. Simple question, simple answer. I appreciate that.

Rico.
Sep 21 '06 #5

P: n/a
>>tbxInputArea.Text of "1,973.00" results in a parsing error,
>>whereas with tbxInputArea.Text of "1.973,00" parsing succeeds.

I doubt that Malaysia uses decimal separators the way the Germans do.

Stop doubting and look it up instead (they do in fact use ',' as
decimal seprator).

I said "Malaysia" , not the Malay number format.

In fact, "1,973.00" is the format coming to us from a big-name enterprise
software and they claim that the decimal separators used are as per
expected in the corresponding country, in this case, Malaysia.
But CultureInfo for "ms-MY", says Malay(Malaysia) so the behaviour is
fine.
Hmm, this is strange. The culture info says decimal separator is comma.
Microsoft's NLS page says the same thing (not surprisingly);
http://www.microsoft.com/globaldev/n...ice%20Pack%202

Wikipedia says dot is used;
http://en.wikipedia.org/wiki/Decimal_point

I found a bunch of other sources that also says dot is used (but most of
them seem to get their info from wikipedia)

The Malaysian Tourist Board (http://www.tourism.gov.my) uses dot as a
decimal separator (see the Currency section at
http://www.tourism.gov.my/en/essentials/default.asp)

I couldn't find an official Malaysian statement about it though. Maybe there
is an official standard that Microsoft uses, but everyone else uses
something different (which would make the standard pretty useless)

/claes
Sep 21 '06 #6

P: n/a
"Claes Bergefall" <lo*****@nospam.nospamwrote in
Hmm, this is strange. The culture info says decimal separator is
comma. Microsoft's NLS page says the same thing (not surprisingly);
http://www.microsoft.com/globaldev/n...bmitted=043E&O
S=Windows%20XP%20Service%20Pack%202

Wikipedia says dot is used;
http://en.wikipedia.org/wiki/Decimal_point

I found a bunch of other sources that also says dot is used (but most
of them seem to get their info from wikipedia)

The Malaysian Tourist Board (http://www.tourism.gov.my) uses dot as a
decimal separator (see the Currency section at
http://www.tourism.gov.my/en/essentials/default.asp)

I couldn't find an official Malaysian statement about it though. Maybe
there is an official standard that Microsoft uses, but everyone else
uses something different (which would make the standard pretty
useless)
You should teach our friend Lebesgue a lesson or two about information
gathering skills. Not only does he have the gall to blast an 8yr neighbour
of Malaysia for mentioning the word 'bug' and doubting his beloved
framework while not *even* knowing the facts.. but he further proudly
relies on the *gasp* Control Panel as an alternate source to confirm what
the .Net framework says (as though not both are from Microsoft) .. Control
Panel.. heh..

Rico.
Sep 22 '06 #7

P: n/a
Oh. My. God. I've got a single question for you. Are you over 13 years old?
Better for you if you are not. Your mental skills are somewhere around that
level.

"Rico" <ra*****@yahoo.comwrote in message
news:Xn****************************@130.133.1.4...
"Claes Bergefall" <lo*****@nospam.nospamwrote in
>Hmm, this is strange. The culture info says decimal separator is
comma. Microsoft's NLS page says the same thing (not surprisingly);
http://www.microsoft.com/globaldev/n...bmitted=043E&O
S=Windows%20XP%20Service%20Pack%202

Wikipedia says dot is used;
http://en.wikipedia.org/wiki/Decimal_point

I found a bunch of other sources that also says dot is used (but most
of them seem to get their info from wikipedia)

The Malaysian Tourist Board (http://www.tourism.gov.my) uses dot as a
decimal separator (see the Currency section at
http://www.tourism.gov.my/en/essentials/default.asp)

I couldn't find an official Malaysian statement about it though. Maybe
there is an official standard that Microsoft uses, but everyone else
uses something different (which would make the standard pretty
useless)

You should teach our friend Lebesgue a lesson or two about information
gathering skills. Not only does he have the gall to blast an 8yr neighbour
of Malaysia for mentioning the word 'bug' and doubting his beloved
framework while not *even* knowing the facts.. but he further proudly
relies on the *gasp* Control Panel as an alternate source to confirm what
the .Net framework says (as though not both are from Microsoft) .. Control
Panel.. heh..

Rico.

Sep 22 '06 #8

P: n/a
Lebesgue wrote:
"Rico" <ra*****@yahoo.comwrote in message
news:Xn****************************@130.133.1.4...
"Claes Bergefall" <lo*****@nospam.nospamwrote in
I couldn't find an official Malaysian statement about it though. Maybe
there is an official standard that Microsoft uses, but everyone else
uses something different (which would make the standard pretty
useless)
You should teach our friend Lebesgue a lesson or two about information
gathering skills. Not only does he have the gall to blast an 8yr neighbour
of Malaysia for mentioning the word 'bug' and doubting his beloved
framework while not *even* knowing the facts.. but he further proudly
relies on the *gasp* Control Panel as an alternate source to confirm what
the .Net framework says (as though not both are from Microsoft) .. Control
Panel.. heh..
Oh. My. God. I've got a single question for you. Are you over 13 years old?
Better for you if you are not. Your mental skills are somewhere around that
level.
Yes.. You most definitely know that fact, and rightly so, of course..

Did the "Control Panel" tell you that?

Just like the "Control Panel" told you that :
[Malaysians] indeed use the decimal separators the way the Germans do.
Even if [i] doubt it.
hehe...

Rico.

Sep 22 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.