parse date/time with comma before millis

65 views
Skip to first unread message

skirmish

unread,
Aug 30, 2018, 7:21:33 PM8/30/18
to golang-nuts
In example code here; https://play.golang.org/p/4P2nH_KE8uu

I'm trying to parse a date time string of the form 2015-09-09 15:21:08,431 but using the format of 2006-01-02 15:04:05,999 (among many others that I've tried) which I'd expect to work, the time.Parse doesn't want to take the format. Looking through time.Parse, it seems it doesn't ever want to accept a comma before millis, is this true? For now, I'm using a strings.Replace to get rid of the comma, but it just feels bad.

I feel like I'm doing it wrong, and as ever I can't change the app generating the data I'm parsing.

--adam

peterGo

unread,
Aug 30, 2018, 8:31:51 PM8/30/18
to golang-nuts
Adam,

In Go, it's usual to hide any ugliness in a function. For example,


Peter
Reply all
Reply to author
Forward
0 new messages