Package org.djunits.formatter
Class Formatter
java.lang.Object
org.djunits.formatter.Formatter
Formatter of values with width and precision.
Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.
- Author:
- Alexander Verbraeck, Peter Knoppers
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault number of fraction digits. -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(double value) Format a floating point value.static Stringformat(double value, int width) Format a floating point value.static Stringformat(double value, int width, int precision) Format a floating point value.(package private) static StringformatString(int width, int precision, String converter) Build a format string.
-
Field Details
-
DEFAULTPRECISION
public static final int DEFAULTPRECISIONDefault number of fraction digits.- See Also:
-
-
Method Details
-
formatString
Build a format string.- Parameters:
width- the number of characters in the resultprecision- the number of fractional digits in the resultconverter- the format conversion specifier- Returns:
- suitable for formatting a float or double
-
format
Format a floating point value.- Parameters:
value- the value to formatwidth- the number of characters in the resultprecision- the number of fractional digits in the result- Returns:
- the formatted floating point value
-
format
Format a floating point value.- Parameters:
value- the value to formatwidth- the number of characters in the result- Returns:
- the formatted floating point value
-
format
Format a floating point value.- Parameters:
value- the value to format- Returns:
- the formatted floating point value
-