Package org.djunits.value.formatter
Class Formatter
java.lang.Object
org.djunits.value.formatter.Formatter
Formatter of values with width and precision.
Copyright (c) 2015-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
- Version:
- $Revision: 954 $, $LastChangedDate: 2022-01-10 03:42:57 +0100 (Mon, 10 Jan 2022) $, by $Author: averbraeck $,
initial version 11 sep. 2015
- Author:
- Alexander Verbraeck, Peter Knoppers
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default number of fraction digits. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
format
(double value, int size) Format a floating point value.static String
format
(double value, int width, int precision) Format a floating point value.static String
format
(float value) Format a floating point value.static String
format
(float value, int size) Format a floating point value.static String
format
(float value, int width, int precision) Format a floating point value.(package private) static String
formatString
(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
- int; the number of characters in the resultprecision
- int; the number of fractional digits in the resultconverter
- String; the format conversion specifier- Returns:
- String; suitable for formatting a float or double
-
format
Format a floating point value.- Parameters:
value
- float; the value to formatwidth
- int; the number of characters in the resultprecision
- int; the number of fractional digits in the result- Returns:
- String; the formatted floating point value
-
format
Format a floating point value.- Parameters:
value
- float; the value to formatsize
- int; the number of characters in the result- Returns:
- String; the formatted floating point value
-
format
Format a floating point value.- Parameters:
value
- float; the value to format- Returns:
- String; the formatted floating point value
-
format
Format a floating point value.- Parameters:
value
- double; the value to formatwidth
- int; the number of characters in the resultprecision
- int; the number of fractional digits in the result- Returns:
- String; the formatted floating point value
-
format
Format a floating point value.- Parameters:
value
- double; the value to formatsize
- int; the number of characters in the result- Returns:
- String; the formatted floating point value
-