I\'m receiving a JSON object with date value like this:
{\"PostingDate\":\"\\/Date(1325134800000-0500)\\/\"}
And I want to parse it in Java
Hier is a working parsing method based on the version of fge but improved as
=>
private static final Pattern bingTimePattern = Pattern.compile("\\/Date\\((\\d+)([-+]\\d+)?\\)\\/");
public static DateTime parseBingTime(String timeAsString) throws ParseException {
Matcher matcher = bingTimePattern.matcher(timeAsString);
if (!matcher.find())
throw new ParseException("wrong date time format " + timeAsString, 0);
final long millis = Long.parseLong(matcher.group(1));
String tz = matcher.group(2);
if (tz.isEmpty())
tz = "+0000";
return new DateTime(millis, DateTimeZone.forID(tz));
}