I am using the Go runtime to store entities in the Appengine Datastore sequenced by the time they were added; to store the timestamp in the key I am formatting the timestamp using the time.Time.String() method and storing the string version as the key.
To get the Time back again on retrieval I use time.Parse:
time.Parse("2006-01-02 15:04:05.000000000 +0000 UTC", the_timestamp)
In unit testing this functionality independent of an app (using cmdline - goapp test) my tests retrieve the timestamp in its entirety no problem.
But when I import the package doing this into an appengine app and test it (using cmdline - goapp serve) the timestamp is stored with its Year field set to "0000"
When you are converting your time to string before saving into datastore, the extra 0s at the end of time are removed. So,
2009-11-10 23:00:00.12300000 +0000 UTC
is converted into
2009-11-10 23:00:00.123 +0000 UTC
Now when you retrieve it from datastore and use the Parse function, it tries to match upto 8 digits after decimal. Hence the error.
So, while converting the time into string, you need to Format the string so that 0s are not lost.
const layout = "2006-01-02 15:04:05.000000000 +0000 UTC"
t := time.Now()
tFormat := t.Format(layout)