Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Hijri Date To gregorian using DateTime.Parse

$
0
0

Dear,

I have the following code snitp to convert from 30/08/1434 to Gregorian , It fails the conversion cause the format is not correct , if you change the date by one day plus or minus with the same format the code works , is this a bug or am I doing something wrong .

Thanks for your help.

 class Program
    {
        static void Main(string[] args)
        {
            CultureInfo arSA = new CultureInfo("ar-SA");
            string dateString;
            DateTime dateValue;

            // Parse date with no style flags.
            dateString = "30/08/1434";
            if (DateTime.TryParseExact(dateString, "dd/MM/yyyy", arSA,
                                       DateTimeStyles.None, out dateValue))
                Console.WriteLine("Converted '{0}' to {1} ({2}).", dateString, dateValue,
                                  dateValue.Kind);
            else
                Console.WriteLine("'{0}' is not in an acceptable format.", dateString);
            Console.ReadLine();
        }
    }


SKA


Viewing all articles
Browse latest Browse all 8156

Trending Articles