1

The Spark Rest API returns time in this format: 2016-10-28T16:56:50.497GMT.

I'm trying to parse that in Go, without any luck. I keep getting 0001-01-01 00:00:00 +0000 UTC, but the time.Parse function doesn't throw any errors:

My function looks like this:

func getTime(timeStamp string) (t time.Time, e error) {
    t, e = time.Parse(
        time.RFC3339Nano,
        timeStamp)
    if e != nil {
        fmt.Errorf("Error parsing timestring", e)
    }
    return t, e
}

I've tried going through the documentation and created my custom layout, but I can't figure out how I should treat that GMT part of the string

1 Answer 1

3

You're trying to parse that time as time.RFC3339Nano, which it is not.

Use the format "2006-01-02T15:04:05.999MST"

https://play.golang.org/p/TYHnvclxEn

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.