Dim dt As DateTime = DateTime.Now Console.WriteLine(dt.Ticks / 1000000000 * 100)
Public Enum enumDateFormat Fullf7 '"MM/dd/yyyy HH:mm:ss.fffffff" Fullf3 '"MM/dd/yyyy HH:mm:ss.fff" DayAndTime '"MM/dd/yyyy HH:mm:ss" DayOnly '"MM/dd/yyyy" End Enum <Runtime.CompilerServices.Extension()> Public Function ToStringリテラル(dt As DateTime, format As enumDateFormat) As String Select Case format Case enumDateFormat.Fullf7 Return dt.ToString("\#MM/dd/yyyy HH:mm:ss.fffffff\#", CultureInfo.InvariantCulture) Case enumDateFormat.Fullf3 Return dt.ToString("\#MM/dd/yyyy HH:mm:ss.fff\#", CultureInfo.InvariantCulture) Case enumDateFormat.DayAndTime Return dt.ToString("\#MM/dd/yyyy HH:mm:ss\#", CultureInfo.InvariantCulture) Case enumDateFormat.DayOnly Return dt.ToString("\#MM/dd/yyyy\#", CultureInfo.InvariantCulture) Case Else Return String.Empty End Select End Function