Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public final class

Formatter

extends Object
java.lang.Object
   ↳ android.text.format.Formatter

Class Overview

Utility class to aid in formatting common values that are not covered by the Formatter class in java.util

Summary

Public Constructors
Formatter ()
Public Methods
static String formatFileSize ( Context context, long number)
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 getHostAddress() , which supports both IPv4 and IPv6 addresses. This method does not support IPv6 addresses.
static String formatShortFileSize ( Context context, long number)
Like formatFileSize(Context, long) , but trying to generate shorter numbers (showing fewer digits of precision).
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Formatter ()

Added in API level 3

Public Methods

public static String formatFileSize ( Context context, long number)

Added in API level 3

Formats a content size to be in the form of bytes, kilobytes, megabytes, etc

Parameters
context Context to use to load the localized units
number size value to be formatted
Returns
  • formatted string with the number

public static String formatIpAddress (int ipv4Address)

Added in API level 3

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".

public static String formatShortFileSize ( Context context, long number)

Added in API level 5

Like formatFileSize(Context, long) , but trying to generate shorter numbers (showing fewer digits of precision).