public
final
class
Formatter
extends Object
java.lang.Object | |
↳ | android.text.format.Formatter |
Utility class to aid in formatting common values that are not covered
by the Formatter
class in java.util
Public constructors | |
---|---|
Formatter()
|
Public methods | |
---|---|
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)
This method was deprecated
in API level 12.
Use |
static
String
|
formatShortFileSize(Context context, long sizeBytes)
Like |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
String formatFileSize (Context context, long sizeBytes)
Formats a content size to be in the form of bytes, kilobytes, megabytes, etc. If the context has a right-to-left locale, the returned string is wrapped in bidi formatting characters to make sure it's displayed correctly if inserted inside a right-to-left string. (This is useful in cases where the unit strings, like "MB", are left-to-right, but the locale is right-to-left.)
Parameters | |
---|---|
context |
Context :
Context to use to load the localized units |
sizeBytes |
long :
size value to be formatted, in bytes |
Returns | |
---|---|
String |
formatted string with the number |
String formatIpAddress (int ipv4Address)
This method was deprecated
in API level 12.
Use getHostAddress()
, which supports both IPv4 and
IPv6 addresses. This method does not support IPv6 addresses.
Returns a string in the canonical IPv4 format ###.###.###.### from a packed integer containing the IP address. The IPv4 address is expected to be in little-endian format (LSB first). That is, 0x01020304 will return "4.3.2.1".
Parameters | |
---|---|
ipv4Address |
int
|
Returns | |
---|---|
String |
String formatShortFileSize (Context context, long sizeBytes)
Like formatFileSize(Context, long)
, but trying to generate shorter numbers
(showing fewer digits of precision).
Parameters | |
---|---|
context |
Context
|
sizeBytes |
long
|
Returns | |
---|---|
String |