Unmarshal incorrectly formatted datetime

前端 未结 2 1070
予麋鹿
予麋鹿 2020-12-28 08:51

Background

I am learning Go and I\'m trying to do some JSON unmarshaling of a datetime.

I have some JSON produced by a program I wrote in C, I am outputtin

2条回答
  •  天涯浪人
    2020-12-28 09:15

    You can try https://play.golang.org/p/IsUpuTKENg

    package main
    
    import (
        "fmt"
        "time"
    )
    
    func main() {
        t, err := time.Parse("2006-01-02T15:04:05.999999999Z0700", "2016-08-08T21:35:14.052975-0200")
        if err != nil {
            panic(err)
        }
        fmt.Println(t)
    }
    
    

提交回复
热议问题