-3

I get a date from a request with this format > 1413972425000

When I execute in JavaScript

new Date(1413972425000)

the result is

Wed Oct 22 2014 11:07:05 GMT+0100 (GMT Daylight Time)

So.. What I want is get the datetime but in Java and I don't know how can I do it.

Thanks.

gon250
  • 3,077
  • 4
  • 39
  • 74

2 Answers2

3

1413972425000 isn't a int value. It is too large for int. You can use it as a long value. 1413972425000L

You can use

Date date=new Date(1413972425000L); // accept long value.
System.out.println(date);
Ruchira Gayan Ranaweera
  • 33,712
  • 16
  • 72
  • 110
2

You can use new Date(1413972425000L) to convert long to date. Note the appended L to the numeric value.

Pramod Karandikar
  • 5,189
  • 7
  • 40
  • 65