I have a Json date with offset. I need to convert that to java.
Edm.DateTime
"/Date(<ticks>["+" | "-" <offset>)/"
<ticks> = number of milliseconds since midnight Jan 1, 1970
<offset> = number of minutes to add or subtract
Using this answer copied below, I am able to convert this date to Java. However, this does not takes into consideration the offset component. Is there any simpler way of resolving the offset.
Date date = new Date(Long.parseLong(jsonDate.replaceAll(".*?(\\d+).*", "$1")));
Below are some String dates that I am getting in the json date format
/Date(1463667774000+0400)/
/Date(1463667774000-5300)/
Program and result below
str = "/Date(1463667774000-9000)/";
date = new Date(Long.parseLong(str.replaceAll(".*?(\\d+).*", "$1")));
System.out.println("1st "+ date);
1st Thu May 19 19:52:54 IST 2016
Can somebody please help?