For a certain API I am getting dates in a /Date(1323312018479-0700)/ format. For some reason the regex that I am using does not result in any matches.
Any ideas?
BTW: I am not taking into account the timezone right now.
public static Date parseApiDate(String rawDate) {
Pattern p = Pattern.compile("([0-9]+)-([0-9]+)", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(rawDate);
Log.d("DATE CONVERSION: Raw", rawDate);
if (m.matches()) {
String utc = m.group(1);
int milliSeconds = Integer.parseInt(utc);
Date date = new Date(milliSeconds);
Log.d("DATE CONVERSION: milliseconds", utc);
Log.d("DATE CONVERSION: Converted", date.toGMTString());
return date;
} else {
return new Date(0);
}
}