简体   繁体   中英

NumberFormat: parse() vs parseObject()

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() ?

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 (eg for UI widgets) then it could be useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM