Formatting program data in Java code

To format program data in Java™ code, you can use the com.fourjs.fgl.lang.FglFormat class implemented in FGLDIR/lib/fgl.jar.

You must add FGLDIR/lib/fgl.jar to the class path in order to compile Java code with com.fourjs.fgl.lang.FglFormat class.

The com.fourjs.fgl.lang.FglFormat class provides an interface to the data formatting functions of the runtime system. This class is actually an equivalent of the USING operator in the language.

The com.fourjs.fgl.lang.FglFormat class implements the following:

Table 1. Methods of the com.fourjs.fgl.lang.FglFormat class
Method Description
static String format(
  int v, 
  String fmt)
Formats the integer value provided as Java int, according to fmt. Here fmt must specify a numeric format with [$@*#&<()+-] characters, as with the USING operator.
static String format(
  double v, 
  String fmt)
Formats the FLOAT value provided as Java double, according to fmt. Here fmt must specify a numeric format with [ $ @*#&<()+-. ,] characters, as with the USING operator.
static String format(
  FglDate v, 
  String fmt)
Formats the DATE value provided as FglDate, according to fmt. Here fmt must specify a date format with [mdy]characters., as with the USING operator.
static String format(
  FglDecimal v, 
  String fmt)
Formats the DECIMAL value provided as FglDecimal, according to fmt. Here fmt must specify a numeric format with [ $ @*# $<()+-. ,] characters, as with the USING operator.
Example of Java code using the com.fourjs.fgl.lang.FglFormat class:
public static void formatDecimal(FglDecimal dec){
    System.out.println( FglFormat.format(dec,"$#####&.&&" );
}