473,769 Members | 6,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

globalization problem

hi,

I have an ASP.NET application with a piece of code that looks like this:

(it is a VB.NET snippet)

Thread.CurrentT hread.CurrentCu lture = New
CultureInfo(Ses sion.Item("Cult ure").ToString )
Thread.CurrentT hread.CurrentUI Culture = New
CultureInfo(Ses sion.Item("Cult ure").ToString )
Dim cultureSpecific Date As Date = Request.QuerySt ring("date").Tr im()
the QueryString object is a key-value collection type, (similar to a
hashtable). It is a NameValueCollec tion to be exact, but I believe that this
is not an important point.

Let say the string returned by Request.QuerySt ring("date").Tr im() is
"20/7/2004 0:00:00"

If the culture loaded at that time is: english then the Date object created
will contain a correct value which is 20/7/2004. But if the culture loaded
is a bit exotic, like the thai culture (which i believe follows a budhist
calendar type), the date object created will be 7/20/1461
That is a problem as later on that date will be used for some SQL commands
and look for that related to the date 20th of july 1461 which obviously does
not exist as the year is tottally different (543 years of difference).

Then I have 2 questions:
1. how can i solve this and always have the right date? (2004 for my SQL
stored procedure). Also I would like a generic solution that will work for
any culture. I would like to avoid any hardcoded date transformation.
2. 2004 in the thai calender correspond 2547 (2004 + 543 = 2547)
Then it seems that when the date object instance is created there is a
problem as it transform 2004 into 1461 (2004 -543 = 1461), which basically
is wrong.

Best regards and tx in advance,

Francois




Nov 18 '05 #1
1 1434
Dates are repersented in many different ways depending on the culture
selected. I believe that Thread.CurrentC ulture is responsible for how a
string containing a date would be parsed.

If your URL parameter is always in the format "day/month/year hh:mm:ss"
yet your Thread.CurrentC ulture varies depending on the user's current
culture set, then you should probably parse the string manually, or
better yet try looking at System.Globaliz ation.DateTimeF ormatInfo. This
way you can leverage .NET to do the parsing of your URL parameter date.

Shan
francois wrote:
hi,

I have an ASP.NET application with a piece of code that looks like this:

(it is a VB.NET snippet)

Thread.Current Thread.CurrentC ulture = New
CultureInfo(Se ssion.Item("Cul ture").ToString )
Thread.Current Thread.CurrentU ICulture = New
CultureInfo(Se ssion.Item("Cul ture").ToString )
Dim cultureSpecific Date As Date = Request.QuerySt ring("date").Tr im()
the QueryString object is a key-value collection type, (similar to a
hashtable). It is a NameValueCollec tion to be exact, but I believe that this
is not an important point.

Let say the string returned by Request.QuerySt ring("date").Tr im() is
"20/7/2004 0:00:00"

If the culture loaded at that time is: english then the Date object created
will contain a correct value which is 20/7/2004. But if the culture loaded
is a bit exotic, like the thai culture (which i believe follows a budhist
calendar type), the date object created will be 7/20/1461
That is a problem as later on that date will be used for some SQL commands
and look for that related to the date 20th of july 1461 which obviously does
not exist as the year is tottally different (543 years of difference).

Then I have 2 questions:
1. how can i solve this and always have the right date? (2004 for my SQL
stored procedure). Also I would like a generic solution that will work for
any culture. I would like to avoid any hardcoded date transformation.
2. 2004 in the thai calender correspond 2547 (2004 + 543 = 2547)
Then it seems that when the date object instance is created there is a
problem as it transform 2004 into 1461 (2004 -543 = 1461), which basically
is wrong.

Best regards and tx in advance,

Francois





Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1434
by: Xavier MT | last post by:
Hi, I have a site that has some text in spanish and it doesn't display well, for example with a ñ it displays some weird boxes, can anyone help me or point me to some help
0
349
by: FM | last post by:
Hi, I use the following code to set the current culture. If Not IsNothing(Session("language")) Then System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(Session("language").ToString) End If
1
1466
by: Michael | last post by:
Hi, I'm developing an ASP.NET application that uses globalization. The language information is stored in .resx-files. For development I use VS.NET 2003, IIS v5.1, Framework v1.1, Windows XP Pro. During the build the resources are correctly compiled into satellite assemblies and stored in the appropriate subfolders. Using the Asp.net application on my local machine produces the expected output. Also the access through the network...
11
7250
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why only that I have to listen to them because they know it better. They told also that in a business situation it is better to use datetime.parseexact for changing cultures and not to use the globalization setting. I did not give them this sample,...
2
3142
by: jason | last post by:
DOTNET 2.0 VS 2005. My client is saying August 13,2006.. julian date should equal 225. Here's what I'm doing: <%@ Import Namespace="system.globalization" %> <script language="VB" runat="server">
1
2375
by: =?Utf-8?B?S3Jpc2huYQ==?= | last post by:
Hi, I am krishna in India.I developed Asp.net application the default culture settings is <globalization culture="en-US" uiCulture="en-US"/>.I need change globalization settings for UK.How to modify the web.config file ?.What is coorect culture for UK and India?. Pls help Thanks in Advance Regards T.A.Krishna
2
5119
by: Terry Olsen | last post by:
I'm a bit confused on how to make my app work in all cultures, particularly with parsing the date out of a string. I read dates from different web sites. The formats I've run into include 'yyyy.mm.dd', 'dd/mm/yyyy', 'yyyy-mm-dd', 'dd-mmm-yyyy'. I'm using the following code to parse the date, which has worked for a lot of Regions but not all, such as Germany. Dim CI As System.Globalization.CultureInfo CI =...
5
1831
by: Basildk | last post by:
Hi. I have a strange problem. We have an asp.net application running on several server with different setups. On 2 of our servers we experience that the globalization settings are misbehaving. We have boiled the problem down to this: (exemplified by a very simple page)
0
3048
by: Sparkiee | last post by:
Hi, A lil bit of help required from you guys, I am trying to make a windows service that will also focus on globalization, the problem i am facing is when i am trying to put globalization code in app.config the windows service throws an error its probably because of using the <system.webin app.config that contains the globalization parameters, copied and pasted from one of my asp.net website where i already used the globalization and i...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10222
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.