rlx
2013-11-28 10:24:09 +08:00
修改了一下。
package main
import (
"time"
"fmt"
"strings"
)
const (
DefaultTimeFormat = "2006-01-02 15:04:05.999999999"
)
func main() {
timeStr := time.Now().Format(DefaultTimeFormat)
timeStr = strings.Replace(timeStr, ".", ",", 1)
fmt.Printf("TimeNow: %s\n", timeStr)
timeStr = "2013-11-26 19:08:17,583492285"
fmt.Println("TimeTransferBefore:", timeStr)
timeStr = strings.Replace(timeStr, ",", ".", 1)
t, err := time.Parse(DefaultTimeFormat, timeStr)
if err != nil {
fmt.Println(err)
return
}
timeStr = t.Format(DefaultTimeFormat)
timeStr = strings.Replace(timeStr, ".", ",", 1)
fmt.Println("TimeTransferAfter:", timeStr)
}