Package htsjdk.samtools.util
Class FormatUtil
java.lang.Object
htsjdk.samtools.util.FormatUtil
Simple class used to format object values into a standard format for printing.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructs a new FormatUtil and initializes various internal formatters. -
Method Summary
Modifier and TypeMethodDescriptionformat
(boolean value) Formats a boolean value to a String.format
(char value) Formats a char as a string.format
(double value) Formats a double to a floating point string.format
(float value) Formats a float to a floating point string.format
(int value) Formats an int to an integer string.format
(long value) Formats a long to an integer string.format
(short value) Formats a short to an integer string.format
(Iso8601Date value) Formats date & timeFormats an enum to the String representation of an enum.Attempts to determine the type of value and format it appropriately.Formats a date to a date string without time.boolean
parseBoolean
(String value) Parses a String into a boolean, as per the above convention that true = Y and false = N.char
Parses a String into a char.Parses a String into a date.double
parseDouble
(String value) Parses a String into a double.<E extends Enum>
EParses a String into an Enum of the given type.float
parseFloat
(String value) Parses a String into a float.int
Parses a String into an int.parseIso8601Date
(String value) Parse a String into an Iso8601 Datelong
Parses a String into a long.parseObject
(String value, Class<?> returnType) Attempts to determine the correct parse method to call based on the desired return type and then parses the String and returns the value.short
parseShort
(String value) Parses a String into a short.
-
Field Details
-
DECIMAL_DIGITS_TO_PRINT
public static final int DECIMAL_DIGITS_TO_PRINT- See Also:
-
-
Constructor Details
-
FormatUtil
public FormatUtil()Constructs a new FormatUtil and initializes various internal formatters. This is necessary because SimpleDateFormat and other formatters are not threadsafe.
-
-
Method Details
-
format
Formats a short to an integer string. -
format
Formats an int to an integer string. -
format
Formats a long to an integer string. -
format
Formats a float to a floating point string. -
format
Formats a double to a floating point string. -
format
Formats a char as a string. -
format
Formats an enum to the String representation of an enum. -
format
Formats a date to a date string without time. -
format
Formats date & time -
format
Formats a boolean value to a String. -
format
Attempts to determine the type of value and format it appropriately. -
parseShort
Parses a String into a short. -
parseInt
Parses a String into an int. -
parseLong
Parses a String into a long. -
parseFloat
Parses a String into a float. -
parseDouble
Parses a String into a double. -
parseEnum
Parses a String into an Enum of the given type. -
parseDate
Parses a String into a date. -
parseIso8601Date
Parse a String into an Iso8601 Date -
parseBoolean
Parses a String into a boolean, as per the above convention that true = Y and false = N. -
parseChar
Parses a String into a char. We expect the String to have a length of exactly one, otherwise throw an exception. -
parseObject
Attempts to determine the correct parse method to call based on the desired return type and then parses the String and returns the value.- Parameters:
value
- the String value to be parsedreturnType
- the desired return type- Returns:
- an object of the returnType
-