Problems with toShortDateString

J

Jesus

Hi!

I'm migrating a web application (ASP.NET) from Framework 1.1 to
Framework 2.0.

I have a problem with that, and I didn't found a solution changing
something in web.config or something like that.

The problem is that when using Framework 1.1, the function
toShortDateString, returns a string with a date at machine culture (in
my case, in spanish). When using Framework 2.0, this function always
returns a string with a date in English culture. The application it
functions depending of the server culture and the user culture, and
when the functions returns always in English, the application don't
works.

I tried to force culture at web.config and change the culture of the
thread in Global.asax, but with no results.

Do you know if this is a bug of Framework 2.0 and if there is a
solution for that? The only thing I know for fix this, is to modify all
the code in the application.

Thanks in advance

Jesus
 
T

Teemu Keiski

Docs state

DateTime.ToShortDateString Method
(http://msdn2.microsoft.com/en-us/library/system.datetime.toshortdatestring.aspx)
*
The value of this instance is formatted using the short date format
character, 'd'. The return value is identical to the value returned by
ToString ("d", null).
For more information about format characters, format patterns, and the
output they produce, see the Formatting Overview topic. For more information
about changing the format pattern associated with a format character see the
DateTimeFormatInfo class.

This method uses formatting information derived from the current culture.
For more information about the current culture, see the CurrentCulture
class. You can use the CultureInfo.DateTimeFormat property to obtain the
DateTimeFormatInfo for the current culture.

*
And with ASP.NET you can change these in <globalization> element in
web.config.
 
J

Jesus

Hi!

Thanks for your answer, Teemu.

This is the how I think this function may work, but it isn't.

If you read this, the function ToShortDateString must return an
string converting a date with the culture of the machine.

This is how it works in ASP.NET 1.1, but in .NET 2.0, this function
always returns an string in format mm/dd/yyyy, even if I change the
culture of the server or the Internet Explorer.

I supose that this is a bug of .NET 2.0, because if I do the same
test in a Win32 Application, it works fine.

If you can show me other way to search, I will be thankful forever.
:)

Thanks in advance

Jesús



Teemu Keiski ha escrito:
 

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