|
|
Title | Get the local and invariate date and time formats in VB .NET |
Description | This example shows how to get the local and invariate date and time formats in VB .NET. |
Keywords | date, time, format, invariate, local, VB.NET |
Categories | Windows, VB.NET, Software Engineering |
|
|
The CultureInfo.CurrentCulture.DateTimeFormat() object gives information about system date and time formats. Its FullDateTimePattern, ShortDatePattern, and ShortTimePattern properties give patterns you can use in ToString to generate formatted dates and times. The InvariantInfo().FullDateTimePattern value gives a pattern for generating an invariate date and time.
|
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
Dim date_info As DateTimeFormatInfo = _
CultureInfo.CurrentCulture.DateTimeFormat()
lblFullDateTime.Text = date_info.FullDateTimePattern
lblShortDate.Text = date_info.ShortDatePattern
lblShortTime.Text = date_info.ShortTimePattern
lblInvariant.Text = _
date_info.InvariantInfo().FullDateTimePattern
lblExFullDateTime.Text = _
Now.ToString(date_info.FullDateTimePattern)
lblExShortDate.Text = _
Now.ToString(date_info.ShortDatePattern)
lblExShortTime.Text = _
Now.ToString(date_info.ShortTimePattern)
lblExInvariant.Text = _
Now.ToString(date_info.InvariantInfo().FullDateTimePattern)
End Sub
|
|
|
|
|
|