Take the 2-minute tour ×

When would it be the case to use parseObject() rather than parse()? I am aware that the first returns an Object and the second a Number, however when is the case of parsing an object different from a Number hence justifying the presence of parseObject()?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

If you know you're dealing with a NumberFormat, there's probably no good reason to. However, if you're in the unusual situation of only knowing about Format, then you don't know what kind of value you're parsing to, and parseObject is all there is.

Personally I don't remember ever using just plain Format on its own, but I suppose if you're in the general "parsing and formatting" business (e.g. for UI widgets) then it could be useful.

share|improve this answer
1 example of parseObject() without returning a Number? –  Rollerball Sep 12 '13 at 21:31
@Rollerball: Sure - if you don't know that it's a NumberFormat, and it might be a DateFormat... –  Jon Skeet Sep 12 '13 at 21:38
add comment

Your Answer


