-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,405
  • 6
  • 44
  • 75

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
  • 34,993
  • 17
  • 75
  • 115
2

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

Pramod Karandikar
  • 5,289
  • 7
  • 43
  • 68