public class FormatUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
formatBytes(long bytes)
Format bytes into a rounded string representation using IEC standard
(matches Mac/Linux).
|
static String |
formatBytesDecimal(long bytes)
Format bytes into a rounded string representation using decimal SI units.
|
static String |
formatDate(org.threeten.bp.LocalDate date)
Convert a java date to a MM-dd-yyyy string representation
|
static String |
formatElapsedSecs(long secs)
Formats an elapsed time in seconds as days, hh:mm:ss.
|
static String |
formatHertz(long hertz)
Format hertz into a string to a rounded string representation.
|
static org.threeten.bp.LocalDate |
formatStringDate(String date)
Convert a MM-dd-yyyy string representation to a java LocalDate
|
static String |
formatValue(long value,
String unit)
Format arbitrary units into a string to a rounded string representation.
|
static long |
getUnsignedInt(int x)
Convert unsigned int to signed long.
|
static String |
join(CharSequence delimiter,
CharSequence... elements)
Returns a new String composed of copies of the CharSequence elements
joined together with a copy of the specified delimiter.
|
static String |
join(CharSequence delimiter,
Iterable<? extends CharSequence> elements)
Returns a new String composed of copies of the CharSequence elements
joined together with a copy of the specified delimiter.
|
static float |
round(float d,
int decimalPlace)
Round to certain number of decimals.
|
static String |
toUnsignedString(int i)
Represent a 32 bit value as if it were an unsigned integer.
|
static String |
toUnsignedString(long l)
Represent a 64 bit value as if it were an unsigned long.
|
public static String formatBytes(long bytes)
formatBytesDecimal(long). For Windows displays for KB, MB and
GB, in JEDEC units, edit the returned string to remove the 'i' to display
the (incorrect) JEDEC units.bytes - Bytes.public static String formatBytesDecimal(long bytes)
formatBytes(long).bytes - Bytes.public static String formatHertz(long hertz)
hertz - Hertz.public static String formatValue(long value, String unit)
value - The valueunit - Units to append metric prefix topublic static String formatElapsedSecs(long secs)
secs - Elapsed secondspublic static float round(float d,
int decimalPlace)
d - Number to be roundeddecimalPlace - Number of decimal places to round topublic static long getUnsignedInt(int x)
x - Signed int representing an unsigned integerpublic static String formatDate(org.threeten.bp.LocalDate date)
date - the date to convertpublic static org.threeten.bp.LocalDate formatStringDate(String date)
date - a string in the form MM/dd/yyyypublic static String toUnsignedString(int i)
i - a 32 bit valuepublic static String toUnsignedString(long l)
l - a 64 bit valuepublic static String join(CharSequence delimiter, CharSequence... elements)
delimiter - the delimiter that separates each elementelements - the elements to join together.public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)
delimiter - a sequence of characters that is used to separate each of the
elements in the resulting Stringelements - an Iterable that will have its elements joined together.Copyright © 2010–2017 oshi. All rights reserved.