Class Formatter
java.lang.Object
de.redstoneworld.redutilities.misc.Formatter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetRationalNumberMsg(Locale locale, double doubleValue, boolean grouping, int minFractionDigits) This method outputs the rational number as a string.static StringgetRationalNumberMsg(Locale locale, float floatValue, boolean grouping, int minFractionDigits) This method outputs the rational number as a string.static doublegetRationalNumberValue(String cmdInput) This method reforms the rational number spelling and convert it to a double number.static StringgetTimeString(long timestamp, String format) This method returns the timestamp in the desired formatting.static StringgetTimeString(Date date, String format) This method returns the date object in the desired formatting.
-
Constructor Details
-
Formatter
public Formatter()
-
-
Method Details
-
getTimeString
This method returns the date object in the desired formatting.- Parameters:
date- (Date) the target date objectformat- (String) the format definition (based of the SimpleDateFormat)- Returns:
- (String) the formatted time string
-
getTimeString
This method returns the timestamp in the desired formatting.- Parameters:
timestamp- (long) the target timestampformat- (String) the format definition (based of the SimpleDateFormat)- Returns:
- (String) the formatted time string
-
getRationalNumberValue
This method reforms the rational number spelling and convert it to a double number. Flexible inputs are allowed, which improves the usability.- Parameters:
cmdInput- the rational number with one of all supported spellings- Returns:
- (double) the formatted rational number (decimal value)
-
getRationalNumberMsg
public static String getRationalNumberMsg(Locale locale, float floatValue, boolean grouping, int minFractionDigits) This method outputs the rational number as a string. This method uses the providedLocaleto format the number according to its specific decimal separator, digit grouping logic and the grouping separator. Example:- Germany (de_DE): 12.345.678,9
- US (en_US): 12,345,678.9
- India (hi_IN): 1,23,45,678.9
- Parameters:
locale- (Locale) the Locale object for the specific micro-typographyfloatValue- (float) the rational numbergrouping- (boolean) Should the character grouping be used?minFractionDigits- (int) The minimum number of decimal digits to show- Returns:
- (String) the formatted string
-
getRationalNumberMsg
public static String getRationalNumberMsg(Locale locale, double doubleValue, boolean grouping, int minFractionDigits) This method outputs the rational number as a string. This method uses the providedLocaleto format the number according to its specific decimal separator, digit grouping logic and the grouping separator. Example:- Germany (de_DE): 12.345.678,9
- US (en_US): 12,345,678.9
- India (hi_IN): 1,23,45,678.9
- Parameters:
locale- (Locale) the Locale object for the specific micro-typographydoubleValue- (double) the rational numbergrouping- (boolean) Should the character grouping be used?minFractionDigits- (int) The minimum number of decimal digits to show- Returns:
- (String) the formatted string
-