Format the current date in (g) General date/short time : Console Format « Development « VB.Net






Format the current date in (g) General date/short time

 

Imports System
Imports Microsoft.VisualBasic

Class Sample
   Private Shared thisDate As DateTime = DateTime.Now

   Public Shared Sub Main()
      Console.Clear()

      Console.WriteLine("Standard DateTime Format Specifiers")
      Console.WriteLine("(d) Short date: . . . . . . . {0:d}" & vbCrLf & _
                        "(D) Long date:. . . . . . . . {0:D}" & vbCrLf & _
                        "(t) Short time: . . . . . . . {0:t}" & vbCrLf & _
                        "(T) Long time:. . . . . . . . {0:T}" & vbCrLf & _
                        "(f) Full date/short time: . . {0:f}" & vbCrLf & _
                        "(F) Full date/long time:. . . {0:F}" & vbCrLf & _
                        "(g) General date/short time:. {0:g}" & vbCrLf & _
                        "(G) General date/long time: . {0:G}" & vbCrLf & _
                        "    (default):. . . . . . . . {0} (default = 'G')" & vbCrLf & _
                        "(M) Month:. . . . . . . . . . {0:M}" & vbCrLf & _
                        "(R) RFC1123:. . . . . . . . . {0:R}" & vbCrLf & _
                        "(s) Sortable: . . . . . . . . {0:s}" & vbCrLf & _
                        "(u) Universal sortable: . . . {0:u} (invariant)" & vbCrLf & _
                        "(U) Universal full date/time: {0:U}" & vbCrLf & _
                        "(Y) Year: . . . . . . . . . . {0:Y}" & vbCrLf, _
                        thisDate)

   End Sub 'Main
End Class

   
  








Related examples in the same category

1.Format a negative integer or floating-point number in Currency format
2.Format a negative integer or floating-point number in Decimal format
3.Format a negative integer or floating-point number in Scientific format
4.Format a negative integer or floating-point number in Fixed point format
5.Format a negative integer or floating-point number in General format
6.Format a negative integer or floating-point number in default format
7.Format a negative integer or floating-point number in Number format
8.Format a negative integer or floating-point number in Percent format
9.Format a negative integer or floating-point number in Round-trip format
10.Format a negative integer or floating-point number in Hexadecimal format
11.Format the current date in (d) Short date
12.Format the current date in (D) Long date
13.Format the current date in (t) Short time
14.Format the current date in (T) Long time
15.Format the current date in (f) Full date/short time
16.Format the current date in (F) Full date/long time
17.Format the current date in (G) General date/long time
18.Format the current date in (M) Month
19.Format the current date in (R) RFC1123
20.Format the current date in (s) Sortable
21.Format the current date in (u) Universal sortable
22.Format the current date in (U) Universal full date/time
23.Format the current date in (Y) Year
24.Format a Color enumeration value in (G) General
25.Format a Color enumeration value in (default)
26.Format a Color enumeration value in (F) Flags
27.Format a Color enumeration value in (D) Decimal number
28.Format a Color enumeration value in (X) Hexadecimal