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 standard java.util.Formatter.

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 addr)
Returns a string in the canonical IP format ###.###.###.### from a packed integer containing the IP address.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Formatter ()

Public Methods

public static String formatFileSize (Context context, long number)

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 formated
Returns
  • formated string with the number

public static String formatIpAddress (int addr)

Returns a string in the canonical IP format ###.###.###.### from a packed integer containing the IP address. The IP address is expected to be in little-endian format (LSB first). That is, 0x01020304 will return "4.3.2.1".

Parameters
addr the IP address as a packed integer with LSB first.
Returns
  • string with canonical IP address format.