I\'m receiving .NET\'s DateTime object as json string through my asmx webservice and trying to parse it with help of gson library. But seems like there\'s no su
To manually convert a .NET JSON date to a JodaTime DateTime object (native Java type similar), you can also use a regex:
public static DateTime parseDotNetTime(String json) {
DateTime result = null;
if (json != null) {
Pattern datePatt = Pattern.compile("^/Date\\((\\d+)([+-]\\d+)?\\)/$");
Matcher m = datePatt.matcher(json);
if (m.matches()) {
Long l = Long.parseLong(m.group(1));
result = new DateTime(l);
// Time zone is not needed to calculate date
} else {
throw new IllegalArgumentException("Wrong date format");
}
}
return result;
}