AnyLogic
Expand
Font size
All Known Implementing Classes:
Agent, Experiment, ExperimentCompareRuns, ExperimentMultipleRuns, ExperimentOptimization, ExperimentParamVariation, ExperimentRunFast, ExperimentSimulation, FlowchartBlock, Utilities

public interface UtilitiesString
Various string utilities, e.g. number formatting.
Author:
AnyLogic North America, LLC https://anylogic.com

Method Summary

Modifier and TypeMethodDescription
static Stringformat(boolean value)
Formats a boolean value
static Stringformat(char value)
Formats a character to String
static Stringformat(double value)
Formats a double value using the default AnyLogic formatter
static Stringformat(double value, IUnits<?> units)
Formats a double value with units, using the default AnyLogic formatter
static Stringformat(int value)
Formats an integer value using the default AnyLogic formatter
static Stringformat(long value)
Formats a long value using the default AnyLogic formatter
static Stringformat(Date date)
Formats a date using the default AnyLogic formatter
static StringformatAmountUnits(double value, AmountUnits units)
Converts value to required units and turns it into String
static StringformatDayOfWeek(int dayOfWeek, boolean fullName)
Returns the full or short name of the weekday
static StringformatFlowRateUnits(double value, FlowRateUnits units)
Converts value to required units and turns it into String
static StringformatLengthUnits(double value, LengthUnits units)
Converts value to required units and turns it into String
static StringformatLengthUnits(LengthUnits unit, boolean fullName)
Returns the full or short name of the length units
static StringformatMonth(int month, boolean fullName)
Returns the full or short name of the month
static StringformatSpeedUnits(double value, SpeedUnits units)
Converts value to required units and turns it into String
static intparseInt(String text)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Inverse operation of format(int)

Method Details

format

static String format(double value)
Formats a double value using the default AnyLogic formatter
Parameters:
value - the double value to be formatted.
Returns:
the string containing the formatted value

format

static String format(double value,
 IUnits<?> units)
Formats a double value with units, using the default AnyLogic formatter
Parameters:
value - the double value to be formatted.
units - units
Returns:
the string containing the formatted value
Since:
8.0

format

static String format(int value)
Formats an integer value using the default AnyLogic formatter
Parameters:
value - the integer value to be formatted.
Returns:
the string containing the formatted value

format

static String format(long value)
Formats a long value using the default AnyLogic formatter
Parameters:
value - the long value to be formatted.
Returns:
the string containing the formatted value

parseInt

@AnyLogicInternalAPI
static int parseInt(String text)
             throws ParseException
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Inverse operation of format(int)
Throws:
ParseException

format

static String format(Date date)
Formats a date using the default AnyLogic formatter
Parameters:
date - the date to be formatted.
Returns:
the string containing the formatted value

formatDayOfWeek

static String formatDayOfWeek(int dayOfWeek,
 boolean fullName)
Returns the full or short name of the weekday
Parameters:
dayOfWeek - one of #MONDAY, #TUESDAY, ... constants
fullName - if true, then returns the full name ("Monday", "Tuesday", etc.), otherwise - short ("Mon", "Tue", etc.)
Returns:
the name of the weekday

formatMonth

static String formatMonth(int month,
 boolean fullName)
Returns the full or short name of the month
Parameters:
month - one of #JANUARY, #FEBRUARY, ... constants
fullName - if true, then returns the full name ("January", "February", etc.), otherwise - short ("Jan", "Feb", etc.)
Returns:
the name of the month

formatLengthUnits

static String formatLengthUnits(LengthUnits unit,
 boolean fullName)
Returns the full or short name of the length units
Parameters:
unit - length units
fullName - if true, then returns the full name ("meter", "foot", etc.), otherwise - short ("m", "ft", etc.)
Returns:
the name of the units

formatAmountUnits

static String formatAmountUnits(double value,
 AmountUnits units)
Converts value to required units and turns it into String
Parameters:
value - value in cubic meters or kilograms
units - required units
Returns:
string representation

formatFlowRateUnits

static String formatFlowRateUnits(double value,
 FlowRateUnits units)
Converts value to required units and turns it into String
Parameters:
value - value in cubic meters per second or kilograms per second
units - required units
Returns:
string representation

formatLengthUnits

static String formatLengthUnits(double value,
 LengthUnits units)
Converts value to required units and turns it into String
Parameters:
value - value in meters
units - required units
Returns:
string representation

formatSpeedUnits

static String formatSpeedUnits(double value,
 SpeedUnits units)
Converts value to required units and turns it into String
Parameters:
value - value in meters per second
units - required units
Returns:
string representation

format

static String format(boolean value)
Formats a boolean value
Parameters:
value - the boolean value to be formatted.
Returns:
the string containing the formatted value ("true" or "false")

format

static String format(char value)
Formats a character to String
Parameters:
value - the character value to be formatted.
Returns:
the string containing the formatted value