The S
pattern won't properly handle a number of milliseconds greater than Integer.MAX_VALUE
, as bizarre as that may seem for a quantity normally expressed as a long.
If you really must use an existing API that demands a DateFormat you can always hack it in:
SimpleDateFormat msSDF = new SimpleDateFormat("SSS") {
@Override
public Date parse(String source) throws ParseException {
return new Date(Long.parseLong(source));
}
};
(May need to also provide a hacked implementation of format(string)
too depending on what your legacy API actually does of course.)