473,397 Members | 1,949 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,397 software developers and data experts.

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.CurrentThread.CurrentCulture = New
CultureInfo(Session.Item("Culture").ToString)
Thread.CurrentThread.CurrentUICulture = New
CultureInfo(Session.Item("Culture").ToString)
Dim cultureSpecificDate As Date = Request.QueryString("date").Trim()
the QueryString object is a key-value collection type, (similar to a
hashtable). It is a NameValueCollection to be exact, but I believe that this
is not an important point.

Let say the string returned by Request.QueryString("date").Trim() 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 1416
Dates are repersented in many different ways depending on the culture
selected. I believe that Thread.CurrentCulture 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.CurrentCulture varies depending on the user's current
culture set, then you should probably parse the string manually, or
better yet try looking at System.Globalization.DateTimeFormatInfo. 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.CurrentThread.CurrentCulture = New
CultureInfo(Session.Item("Culture").ToString)
Thread.CurrentThread.CurrentUICulture = New
CultureInfo(Session.Item("Culture").ToString)
Dim cultureSpecificDate As Date = Request.QueryString("date").Trim()
the QueryString object is a key-value collection type, (similar to a
hashtable). It is a NameValueCollection to be exact, but I believe that this
is not an important point.

Let say the string returned by Request.QueryString("date").Trim() 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
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
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...
1
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...
11
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...
2
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"...
1
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...
2
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...
5
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....
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.