Using CultureInfo to modify output

posted by Scudyen date: Thursday, May 22, 2008 category: ASP.NET

     

Using CultureInfo to modify output

October 27, 2003

Mostly we want to change output results of our applications to another culture setting. In this code sniplet we will format current date time for our culture settings. 

Now first let's see which culture settings and outputs we can change.

en-US 4/10/2001
en-NZ 10/04/2001
de-DE 10.04.2001
en-US Tuesday, April 10, 2001
en-US 3:51:24 PM
es-ES 15:51:24
en-US Tuesday, April 10, 2001 3:51 PM
fr-FR mardi 10 avril 2001 15:51
en-US Tue, 10 Apr 2001 15:51:24 GMT
zh-SG Tue, 10 Apr 2001 15:51:24 GMT
en-US 2001-04-10T15:51:24
pt-BR 2001-04-10T15:51:24
en-US 2001-04-10 15:51:24Z
sv-FI 2001-04-10 15:51:24Z
en-US April 10
ms-MY 10 April
en-US April, 2001
af-ZA April 2001
en-UZ Unrecognized format specifier; a format exception is thrown.

 

And now we are formating date time for France (fr-FR). To understand output we will format a long date time.

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Globalization" %>
<script language="VB" runat="server">

 Sub Page_Load(Source as Object, E as EventArgs)

 Dim dt As DateTime = DateTime.Now
 Dim strCultureInfo As CultureInfo = New CultureInfo("fr-FR")
 response.write( dt.ToString("f", strCultureInfo ) )
 end sub
</script>

Our out will be like this :

lundi 27 octobre 2003 22:54

 

Read More

Custom Search



Gazatem Technologies Active News Manager


page counter

Listed with 411asp.net Listed with 4aspin.com