if I use this line of code on an azure website
DateTime.Now.ToString(new System.Globalization.CultureInfo("it-IT"))
the page prints
13/02/2014 12.08.45
but the time separator is wrong, should be
13/02/2014 12:08:45
Am I doing something wrong or is an azure bug?
EDIT
I run the test program Jon Skeet suggest me, and these are the results
PS D:\desktop> .\test
13/02/2014 12:50:32
Runtime: 2.0.50727.5472
PS D:\desktop> .\test
13/02/2014 12:50:47
Runtime: 4.0.30319.18408
I believe it's to do with the version of the CLR being used. On the CLR prior to v4, the culture information being used did have the time separator as .
. On CLR v4+, it's :
. I don't know why... presumably CLR v4+ is reading the regional information from a different (newer?) location. (I suspect it's down to the CLR version being used, basically.)
Anyway, I suspect if you can force your Azure service to use .NET 4, it will be okay. I suspect you'll find it's using .NET 3.5 at the moment.
As an example, take this code:
using System;
using System.Globalization;
class Test
{
static void Main()
{
CultureInfo culture = new CultureInfo("it-IT");
Console.WriteLine(DateTime.Now.ToString(culture));
Console.WriteLine("Runtime: {0}", Environment.Version);
}
}
Compile it with the C# 2 compiler:
c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc Test.cs
And create a Test.exe.config file:
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Comment out one of those supportedRuntime
elements at a time to see the difference.
See more on this question at Stackoverflow