public class FormatUtils extends Object
Modifier and Type | Field and Description |
---|---|
static double |
DAY |
static double |
HOUR |
static String |
JAVA_UTIL_DATE_TO_STRING_FORMAT
This is the format produced by the
toString() method of java.util.Date instance |
static double |
MINUTE |
static double |
SECOND |
static double |
YEAR |
Constructor and Description |
---|
FormatUtils() |
Modifier and Type | Method and Description |
---|---|
static long |
getBytes(String size)
Parse bytes from a size string that ends with a unit of measure.
|
static long |
getBytes(String size,
List<String> tokens,
int base) |
protected static long |
getByteValue(String time,
String suffix,
long multiplier) |
static String |
getCount(long count)
Return a formatted
count |
static String |
getCurrency(double number) |
static String |
getDate(Date date)
Return a formatted date
|
static String |
getDate(long millis)
Return a formatted date
|
static String |
getFormattedSize(long bytes,
Size size) |
static String |
getIntegerSize(long bytes)
Given a number of bytes return bytes, kilobytes, megabytes, gigabytes, terabytes, petabytes, or exabytes as appropriate.
|
static String |
getIntegerSize(long bytes,
Size unitOfMeasure)
Given a number of bytes return a string formatted into the unit of measure indicated
|
static long |
getMillis(String time)
Parse milliseconds from a time string that ends with a unit of measure.
|
static long |
getMillis(String time,
List<String> tokens,
List<Long> multipliers) |
static int |
getMillisAsInt(String time)
Parse milliseconds from a time string that ends with a unit of measure.
|
static String |
getRate(long millis,
long bytes)
Given a number of bytes and the number of milliseconds it took to transfer that number of bytes, return bytes/s, KB/s, MB/s, GB/s, TB/s, PB/s, or EB/s as appropriate
|
static String |
getRate(long millis,
long bytes,
NumberFormat rateFormatter)
Given a number of bytes and the number of milliseconds it took to transfer that number of bytes, return bytes/s, KB/s, MB/s, GB/s, TB/s, PB/s, or EB/s as appropriate
|
static String |
getSize(long bytes)
Given a number of bytes return bytes, kilobytes, megabytes, gigabytes, terabytes, petabytes, or exabytes as appropriate.
|
static String |
getSize(long bytes,
NumberFormat formatter)
Given a number of bytes return a string formatted into the unit of measure indicated
|
static String |
getSize(long bytes,
Size unitOfMeasure)
Given a number of bytes return a string formatted into the unit of measure indicated
|
static String |
getSize(long bytes,
Size unitOfMeasure,
NumberFormat formatter)
Given a number of bytes return a string formatted into the unit of measure indicated
|
static Size |
getSizeEnum(double bytes) |
static String |
getThroughputInSeconds(long millis,
long count,
String label) |
static String |
getTime(long millis)
Given milliseconds, return milliseconds, seconds, minutes, hours, days, or years as appropriate.
|
static String |
getTime(long millis,
NumberFormat formatter)
Given milliseconds, return milliseconds, seconds, minutes, hours, days, or years as appropriate.
|
static String |
getTime(com.google.common.base.Stopwatch stopwatch)
Given a stopwatch, return milliseconds, seconds, minutes, hours, days, or years as appropriate.
|
protected static List<Long> |
getTimeMultipliers() |
protected static long |
getTimeValue(String time,
String suffix,
long multiplier) |
static Date |
parseDate(String date)
Parse a date from the string.
|
public static final double SECOND
public static final double MINUTE
public static final double HOUR
public static final double DAY
public static final double YEAR
public static final String JAVA_UTIL_DATE_TO_STRING_FORMAT
toString()
method of java.util.Date
instancepublic FormatUtils()
public static String getCurrency(double number)
public static long getBytes(String size)
1 == 1 byte 1b == 1 byte 1k == 1 kilobyte == 1024 bytes == 1,024 bytes 1m == 1 megabyte == 1024^2 bytes == 1,048,576 bytes 1g == 1 gigabyte == 1024^3 bytes == 1,073,741,824 bytes 1t == 1 terabyte == 1024^4 bytes == 1,099,511,627,776 bytes 1p == 1 petabyte == 1024^5 bytes == 1,125,899,906,842,624 bytes 1e == 1 exabyte == 1024^6 bytes == 1,152,921,504,606,846,976 bytes
protected static long getByteValue(String time, String suffix, long multiplier)
public static long getMillis(String time)
1 == 1 millisecond 1ms == 1 millisecond 1s == 1 second == 1000 milliseconds 1m == 1 minute == 60,000 milliseconds 1h == 1 hour == 3,600,000 milliseconds 1d == 1 day == 86,400,000 milliseconds 1y == 1 year == 31,536,000,000 milliseconds
public static int getMillisAsInt(String time)
1 == 1 millisecond 1ms == 1 millisecond 1s == 1 second == 1000 milliseconds 1m == 1 minute == 60,000 milliseconds 1h == 1 hour == 3,600,000 milliseconds 1d == 1 day == 86,400,000 milliseconds 1y == 1 year == 31,536,000,000 milliseconds
protected static long getTimeValue(String time, String suffix, long multiplier)
public static Date parseDate(String date)
public static String getThroughputInSeconds(long millis, long count, String label)
public static String getRate(long millis, long bytes)
public static String getRate(long millis, long bytes, NumberFormat rateFormatter)
public static String getTime(long millis)
public static String getTime(com.google.common.base.Stopwatch stopwatch)
public static String getTime(long millis, NumberFormat formatter)
public static String getSize(long bytes)
public static String getIntegerSize(long bytes)
public static String getIntegerSize(long bytes, Size unitOfMeasure)
public static String getSize(long bytes, NumberFormat formatter)
public static String getSize(long bytes, Size unitOfMeasure, NumberFormat formatter)
public static String getSize(long bytes, Size unitOfMeasure)
public static String getFormattedSize(long bytes, Size size)
public static Size getSizeEnum(double bytes)
protected static final List<Long> getTimeMultipliers()
Copyright © 2010–2014 The Kuali Foundation. All rights reserved.