IFormatProvider DateTime C#.net

IFormatProvider DateTime C#.net

IFormatProvider example to parse DateTime in [C#.net] and [vb.net]

C#-Format

[C#] .net DateTime Parse with IFormatProvider Example.

using System;
using System.Globalization;
namespace DateAndTime.Examples
{
class Program
{
static void Main(string[] args)
{
IFormatProvider formatProvider = new CultureInfo("en-GB");
DateTime formatExample = DateTime.Parse("31-12-2012",formatProvider);
Console.WriteLine("DateTime Parse with FormatProvider {0} .", formatExample);     
Console.ReadLine();
}
}
}
VB.net-Program

(VB.net) IFormatProvider DateTime Parse example

Imports System.Globalization
Namespace DateAndTime.Examples
Class Program
Private Shared Sub Main(args As String())
Dim formatProvider As IFormatProvider = New CultureInfo("en-GB")
Dim formatExample As DateTime = DateTime.Parse("31-12-2012", formatProvider)
Console.WriteLine("DateTime Parse with FormatProvider {0} .", formatExample)
Console.ReadLine()
End Sub
End Class
End Namespace
Output

DateTime Parse with FormatProvider 12/31/2012 12:00:00 AM .

Other Examples

How to format Time in C#.net and VB.net program.
DateTime Time Format string {HH:mm:ss}.
C#.net date time Culture.
C#.net DateTime Month.
string was not recognized as a valid date time
Get Today
DateTime in English UK format
Get Day Of year
DateTime.Today vs DateTime.Now
DateTime Parse Exact method.
Parse Exact DateTime

Tags:

DateTimeTryParse using C# and VB.net exampleDateTime.Today Vs DateTime.NowDateTimeTryParse with IFormatProvider culture information using c#C# DateTime DifferenceC# Parse method of DateTimeC# DateTimeAsp.net Cache ObjectC# DateTime ToString()C#.net Get Yesterday.DateTime ParseExact Time 10:10:13 AM hh mm ss tt nullC#.net get tomorrows date

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.