0

I'm fairly new in Scala. I want to convert timestamp value to a readable date time string but I'm getting weird result. Not sure what I'm missing.

On Scala shell, if I type this:

scala> var  formatter = new java.text.SimpleDateFormat("yyyy/MM HH:mm:ss:SSS");
formatter: java.text.SimpleDateFormat = java.text.SimpleDateFormat@70e82faa
scala>  println(formatter.format(new java.util.Date(1450757349)))
1970/01 10:59:17:349

But if I use Epoch converter, 1450757349 is actually:

Tue, 22 Dec 2015 04:09:09 GMT

So what I'm missing? I tried Jodatime library also, but got the same result

var res = new DateTime(1450757349).toString("yyyy-MM-dd HH:mm:ss")
dreamer
  • 1,039
  • 2
  • 16
  • 36

0 Answers0