public final class Formatter extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Formatter.BytesResult |
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_CALCULATE_ROUNDED |
static int |
FLAG_SHORTER |
Constructor and Description |
---|
Formatter() |
Modifier and Type | Method and Description |
---|---|
static Formatter.BytesResult |
formatBytes(Resources res,
long sizeBytes,
int flags) |
static String |
formatFileSize(Context context,
long sizeBytes)
Formats a content size to be in the form of bytes, kilobytes, megabytes, etc.
|
static String |
formatIpAddress(int ipv4Address)
Deprecated.
Use
InetAddress.getHostAddress() , which supports both IPv4 and
IPv6 addresses. This method does not support IPv6 addresses. |
static String |
formatShortElapsedTime(Context context,
long millis)
Returns elapsed time for the given millis, in the following format:
1 day 5 hrs; will include at most two units, can go down to seconds precision.
|
static String |
formatShortElapsedTimeRoundingUpToMinutes(Context context,
long millis)
Returns elapsed time for the given millis, in the following format:
1 day 5 hrs; will include at most two units, can go down to minutes precision.
|
static String |
formatShortFileSize(Context context,
long sizeBytes)
Like
formatFileSize(android.content.Context, long) , but trying to generate shorter numbers
(showing fewer digits of precision). |
public static final int FLAG_SHORTER
public static final int FLAG_CALCULATE_ROUNDED
public static String formatFileSize(Context context, long sizeBytes)
context
- Context to use to load the localized unitssizeBytes
- size value to be formatted, in bytespublic static String formatShortFileSize(Context context, long sizeBytes)
formatFileSize(android.content.Context, long)
, but trying to generate shorter numbers
(showing fewer digits of precision).public static Formatter.BytesResult formatBytes(Resources res, long sizeBytes, int flags)
@Deprecated public static String formatIpAddress(int ipv4Address)
InetAddress.getHostAddress()
, which supports both IPv4 and
IPv6 addresses. This method does not support IPv6 addresses.public static String formatShortElapsedTime(Context context, long millis)
context
- the application contextmillis
- the elapsed time in milli secondspublic static String formatShortElapsedTimeRoundingUpToMinutes(Context context, long millis)
context
- the application contextmillis
- the elapsed time in milli seconds