473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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
8 6119
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
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
"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
"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
>>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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rerdavies | last post by:
OS: WIndows Server 2003. Currently logged in user is running with German(German) regional settings. Code fragment: System.Globalization.CultureInfo culture = new...
12
by: magister | last post by:
Hello, I know I can set the Culture to what I want, but shouldn't the current culture be taken from the regional settings on the web server's control panel!!! Mine is set to "united kingdom"...
0
by: Dan | last post by:
Hi, I'm having a really basic problem parsing a simple UK date string. The following line works fine in a WinForms app, but not in my ASP.net form: DateTime dt = DateTime.Parse("23/10/2005",...
38
by: nobody | last post by:
I know that given a FormatString and a DateTime you can use DateTime.ToString(...) to convert the DateTime to a String. My question is how can you turn that around? Given a String and a...
2
by: Giorgio | last post by:
I would to format the date in Italian ...(dd/mm/yyyy) I have set an another language in International setting(for test i have set Lettonia) The format date for this nation is yyyy.mm.dd ... I...
2
by: sherifffruitfly | last post by:
Hi, I'm using an adaptation of excel-reading code that's all over the internet - I don't much like or understand it, but it has worked for me in the past.... beggars can't be choosers... : ...
3
by: Hector | last post by:
Hi, My application supports different languages, and i have a problem with the decimals: In this application, i receive datas like "10.528". When i use CurrentCulture = "en-US", no problem....
4
by: =?Utf-8?B?d2luZHNpbQ==?= | last post by:
Hi, I have a c# program where I need a numerical float input. Due to the culture difference, someone is used to type f.ex. 1,3; 2,32 (, comma) while others use 1.3; 2.32(. point) etc. so the...
8
by: =?Utf-8?B?T2xpdmllciBHSUw=?= | last post by:
Hello, I try to convert a volume stored as a string value in an XML file into a Decimal object. The volume is stored with comma as decimal separator ("210,12") according to french habits. To be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.