International Number formats

19 July, 2006

Show comments

Perhaps this will be useful for others.

I needed to be able to convert decimal number to and from the 'local' format. By adding the below methods to my app_model, it is possible to silently convert decimal numbers as they come out of the database to be local format, and vice versa to save. In the code below it is converting numbers of the format 999.999,99 to be 999999.99 - which otherwise would be saved by MySql as 999.99 as the rest of the number is ignored.