Why Date Fail to Parse this string?

-4

"9/28/2019 12:58:29 PM"

            Dim previousTimeStamp = Date.Parse(timestampString)

Shows error

+       Date.Parse(timestampString) 'Date.Parse(timestampString)' threw an exception of type 'System.FormatException'   Date {System.FormatException}

System.FormatException
  HResult=0x80131537
  Message=String was not recognized as a valid DateTime.
  Source=mscorlib
  StackTrace:
   at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
   at nicehash.CoinClass.TrimTentative() in H:\business\shared\Dropbox\vb.net\coinmarketcap.vb:line 451
   at nicehash.CoinClass.VB$StateMachine_30_dealWithOldCheckThisURL.MoveNext() in H:\business\shared\Dropbox\vb.net\coinmarketcap.vb:line 401
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at nicehash.coinmarketcap.VB$StateMachine_1_mainLoopRepeat.MoveNext() in H:\business\shared\Dropbox\vb.net\coinmarketcap.vb:line 1992

The code worked just fine. Somehow it didn't work.

Update: The currentculture can't possibly be the problem because the code used to work. The string changes all the time but the strings are timestamp created by vb.net itself. So it is a valid date string?

vb.net
asked on Stack Overflow Sep 29, 2019 by user4951 • edited Sep 30, 2019 by user4951

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0