How do I parse this date format:
"/Date(1514728800000+0300)/"
I don't know what the meaning of this number is, or that of the +
sign.
How do I parse this date format:
"/Date(1514728800000+0300)/"
I don't know what the meaning of this number is, or that of the +
sign.
Partial answer: the number is the epoch time.
This is the amount of seconds since Jan 1, 1970, UTC.
You can pass this value to the constructor of java.util.Date, which will get you a Date
object with the right value.
The +0300 is unclear, perhaps a reference to a different timezone.
Im not sure about the +0300, but you can convert a epoch time to Date with the following function:
Date date = new Date(Long.parseLong(myDateToParse.replaceAll("[^\\d-]", "")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss", Locale.DEFAULT);
Here is the code that parses this assuming you have unixtimestamp_zoneoffset
String inputStr = "1514728800000+0300";
String[] splitStr = inputStr.split("[+-]");
String offsetSign = inputStr.indexOf("+")>0 ? "+" : "-";
ZonedDateTime captureTime = Instant.ofEpochMilli(Long.valueOf(splitStr[0])).atZone(ZoneOffset.of(offsetSign+splitStr[1]));
The value returned is 2017-12-31T17:00+03:00