Menu

#4 DecimalFormat problems generating PDF file

Unstable (example)
open
nobody
None
5
2013-08-05
2013-08-05
No

In the file PDFGraphics.java the DecimalFormat variable df is used to format floating point number.
The problem is that with different locales (like DUTCH) the decimal seperator is a comma. The PDF file-format doesn't support a comma as decimal seperator. I solved it by applying the following hack:

static  DecimalFormatSymbols getDecimalFormatSymbols() 
{
    DecimalFormatSymbols dfs = new DecimalFormatSymbols();
    dfs.setDecimalSeparator('.');
    return dfs;
}   
private static final DecimalFormat df = new DecimalFormat("#.###",getDecimalFormatSymbols());

Discussion


Log in to post a comment.