// Convert to String g from double d
// 2 decimal places, with comma, rounded, locale-sensitive.

import java.text.DecimalFormat;

//...

// Normally you would create your patterns in static init to avoid
// the overhead of creating them on every conversion.
// Beware DecimalFormat is not thread safe.
DecimalFormat df2 = new DecimalFormat( "###,##0.00" );
g = df2.format( d );

// or exponential scientific format, locale-sensitive.
DecimalFormat de = new java.text.DecimalFormat( "0.0000000000E00" );
g = de.format( d );